rasool forghani
rasool forghani

Reputation: 11

how to count something in multiple columns in google sheets?

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:

enter image description here

Upvotes: 1

Views: 5610

Answers (3)

Tom Sharpe
Tom Sharpe

Reputation: 34230

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"))

enter image description here

Upvotes: 1

marikamitsos
marikamitsos

Reputation: 10573

You could use a Pivot table

Have a look at the attached spreadsheet
https://docs.google.com/spreadsheets/d/....

Google sheets Pivot table

Please read more about how to create and use Pivot Tables

Upvotes: 2

Fernand
Fernand

Reputation: 1333

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).

Upvotes: 0

Related Questions