Count Distinct Rows Using AND and OR
Hi geniuses. I need help with a formula. I have a sheet that looks like this:
I need to get a count of distinct rows that are Type = Task AND have (Past Due = 1 OR Jeopardy Status = Red). I assume I'll need to use COUNTIFS with OR and DISTINCT, but I'm not sure how to structure it. Thoughts? Thank you very much.
Best Answer
-
Hi @Lori Drum
Since you have some rows that could potentially have both a Flag and a Red ball but you only want to count that row once, the way I would do this is to create three separate formulas:
First, count the Red status rows. Then, add this to the count of the flag rows. Finally, minus the count of the rows that have both from the total. This will give you the Distinct count!
Try this:
=COUNTIF([Past Due]:[Past Due], 1) + COUNTIF([Jeopardy Status]:[Jeopardy Status], "Red") - COUNTIFS([Past Due]:[Past Due], 1, [Jeopardy Status]:[Jeopardy Status], "Red")
Cheers,
Genevieve
Need more help? 👀 | Help and Learning Center
こんにちは (Konnichiwa), Hallo, Hola, Bonjour, Olá, Ciao! 👋 | Global Discussions
Answers
-
Hi @Lori Drum
Since you have some rows that could potentially have both a Flag and a Red ball but you only want to count that row once, the way I would do this is to create three separate formulas:
First, count the Red status rows. Then, add this to the count of the flag rows. Finally, minus the count of the rows that have both from the total. This will give you the Distinct count!
Try this:
=COUNTIF([Past Due]:[Past Due], 1) + COUNTIF([Jeopardy Status]:[Jeopardy Status], "Red") - COUNTIFS([Past Due]:[Past Due], 1, [Jeopardy Status]:[Jeopardy Status], "Red")
Cheers,
Genevieve
Need more help? 👀 | Help and Learning Center
こんにちは (Konnichiwa), Hallo, Hola, Bonjour, Olá, Ciao! 👋 | Global Discussions
-
Thank you, Genevieve! That will work just fine. I appreciate the help.
Help Article Resources
Categories
- All Categories
- 14 Welcome to the Community
- Customer Resources
- 64.6K Get Help
- 433 Global Discussions
- 136 Industry Talk
- 465 Announcements
- 4.9K Ideas & Feature Requests
- 143 Brandfolder
- 147 Just for fun
- 63 Community Job Board
- 466 Show & Tell
- 32 Member Spotlight
- 2 SmartStories
- 298 Events
- 36 Webinars
- 7.3K Forum Archives
Check out the Formula Handbook template!