I'll start off by saying that I'm not very familiar w/ google sheets and its formulas.
How would I go about solving this?
I have two columns: A and B. I want to count the cells under column B under these conditions:
look at rows under column B where its corresponding values in column A are not duplicates.
Would this require multiple steps?
try:
=COUNTA(IFNA(FILTER(B1:B, REGEXMATCH(B1:B&"",
TEXTJOIN("|", 1, FILTER(A1:A, COUNTIF(A1:A, A1:A)=1))))))
Related
I am trying to sum values for individual people who have multiple rows in one column and values (prices) in another. I am trying to have a column for the summed values for each person. Right now I am using =sum for each individual person but am looking for a way to code/use a formula to streamline the process.
use:
=QUERY(A:B; "select A,sum(B) where A is not null group by A label sum(B)''")
I'm trying to put together an investment tracking sheet. For the overview page, I want to query and combine data from each of the account tabs but I'm having difficulty figuring out how to make that work.
Here's a link to my test sheet: https://docs.google.com/spreadsheets/d/14sZmxkM65ax9BKrkjinwOrOQPrS_xhqPPLs68Rggii4/edit
The formula I tried to use is in column J on the Overview tab. This formula works in Excel, but not Google Sheets:
=IF(F2<>"",SUMPRODUCT(SUMIF(INDIRECT("'"&Accounts&"'!"&"$N$2:$N$1000"),F2,INDIRECT("'"&Accounts&"'!"&"$O$2:$O$1000"))),"")
Accounts is a named range with the 4 account tab names
Column N on each account tab has the stock name
Column O on each account tab has the share count
Column F on the Overview tab has the stock names to match
If I run the same spreadsheet in Excel, the above formula works correctly and the share counts are correctly added from the 4 accounts: 120/20/50/101.
In google sheets I understand that INDIRECT doesn't support arrays, so it only shows the share counts from the first account: 100/20/0/0
So my question is if anyone can tell me how to modify the formulas from column J to work in Google Sheets?
Thank you.
delete your whole column J and use this:
=ARRAYFORMULA(IFNA(VLOOKUP(F2:F, QUERY(
{Account1!N:O; Account2!N:O; Account3!N:O; Account4!N:O},
"select Col1,sum(Col2)
where Col1 is not null
group by Col1"), 2, 0)))
I have a Google Sheet (Test Sheet 2) with two sheets in it, Sheet 1 and Sheet 2. Sheet 2 is where all of the data is and I need to get the sums of the counts of that column based on three criteria into sheet 1 column C. The name, week, year and count need to match up. I used the formula
=arrayformula(iferror(vlookup(A2:A&2020&B2:B, {Sheet2!A2:A&Sheet2!B2:B&Sheet2!C2:C, Sheet2!D2:D}, 2, FALSE)))
but that only works for unique rows. In the example sheet I am providing, the formula works well for Bill, Lisa, Katie and Jon because they all have one value for 'count' from Sheet2 when the parameters of name, week and year match up. But Mike has two rows matching the criteria. This formula returns the first match which is 3. The other value is 4 so I would like the count in Sheet1 to show 7 instead of 3. I need it to add them up.
I also tried to use sumifs but the columns are two different sizes so that didn't work.
Any idea? I did try to combine sumif with the above formula but that did not work either.
Link to Test Sheet
Solution with ARRAYFORMULA and SUMIF
If you need to use ARRAYFORMULA to improve the performances you can use this tweak of the SUMIF statement: basically you can concatenate the conditions to make them create a single AND condition.
This would be a possible solution for the formula in your comment:
=ARRAYFORMULA(SUMIF(Sheet2!A2:A&Sheet2!B2:B,A2:A&2020,Sheet2!D2:D))
Solution with SUMIFS
If you are looking for a solution with the SUMIFS formula you can use this:
SUMIFS('sum_range', 'criteria_range', condition, ['criteria_range_2', condition_2])
In your case this will translate to:
=SUMIFS(Sheet2!D2:D, Sheet2!A2:A, A2, Sheet2!B2:B, 2020)
In this case the ranges dimensions won't affect the formula execution.
Just drag this formula for the Sheet1 table column and you will get the results. The drawback is that you cannot use ARRAYFORMULA with SUMIFS. Performance wise, if you have a lot of rows in the Sheet1 I suggest using the ARRAYFORMULA solution, since this will trigger a lot of formula calls instead of just one.
Try this query()
=query(Sheet2!A:D, "Select A, C, sum(D) where B = 2020 group by A, C label C 'Week', sum(D) 'Count'", 1)
UPDATED:
If you really need to use vlookup in arrayformula() you can always ise the query (that deals with the summing) as the lookup range. In the spreadsheet I used
=ArrayFormula(if(len(A2:A), iferror(vlookup(A2:A&year(D2:D)&E2:E, query({Sheet2!A:A&Sheet2!B:B&Sheet2!C:C, Sheet2!D:D}, "Select Col1, sum(Col2) where Col1 <>'' group by Col1", 1), 2, 0)),) )
and see if that helps?
I need to count items per person per date in google sheets. What formula do you recommend for?
I write this but it does not work:
=countifs(A2:A11, "3/14/2020", B2:B11, "person1", D2:H11, "*")
View image:
You could use a Pivot table
Have a look at the attached spreadsheet
https://docs.google.com/spreadsheets/d/....
Please read more about how to create and use Pivot Tables
Another way is to use the mmult method to get the row totals, then follow it with a grouping or pivot query:
=ArrayFormula(query({A2:B11,mmult(n(D2:H11="*"),transpose(column(D2:H11)^0))},"select Col2,Col1,sum(Col3) group by Col2,Col1"))
or
=ArrayFormula(query({A2:B11,mmult(n(D2:H11="*"),transpose(column(D2:H11)^0))},"select Col2,sum(Col3) group by Col2 pivot Col1"))
Since the range of first criteria is only one column, succeeding criteria should also use the same range, one column.
B2:B11, "person1", D2:D11, "*", E2:E11, "*" ...
reference: Each additional range must have the same number of rows and columns as the first range (criteria_range1 argument).
I have this formula in D1:
=arrayformula(IFERROR(VLOOKUP(A1:C,H1:K,{4},0)))
I'm trying to match columns A,B,C with columns H,I,J and pull data in column K. The formula is currently not matching correctly. Here is the sheet.
the first argument of VLOOKUP needs to be a single column so the only way how to pull this of with 3 columns is like this:
=ARRAYFORMULA(IFERROR(VLOOKUP(A1:A&B1:B&C1:C, {H1:H&I1:I&J1:J, K1:K}, 2, 0)))