Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
scoutmedic
Helper I
Helper I

Counting rows with multiple conditions

Hi all, 

 

I have a table with 2 columns: area and error and need to count rows where area = floor and errors are apple, orange, grapes, and watermelon. I tried using the following which worked well for me in another situation with 2 criteria, but AND doesn't work with multiple criteria:

 

Errors = CALCULATE(COUNTROWS('Error table'),
AND(CONTAINSSTRING('Combined Error Data'[Area], "Floor"), CONTAINSSTRING('Combined Error Data'[Category Detail], "apple")),
AND (CONTAINSSTRING('Combined Error Data'[Category], "Floor"), CONTAINSSTRING('Combined Error Data'[Category Detail], "orange")),
AND (CONTAINSSTRING('Combined Error Data'[Category], "Floor"), CONTAINSSTRING('Combined Error Data'[Category Detail], "grapes")),
AND (CONTAINSSTRING('Combined Error Data'[Category], "Floor"), CONTAINSSTRING('Combined Error Data'[Category Detail], "watermelon"))
 
I tried && in place of the ANDs, but that didn't work either. 
 
I thought about creating measures and trying to combine the, but no luck either.
 
Thoughts on how I can rewrite this?
1 ACCEPTED SOLUTION
PhilipTreacy
Super User
Super User

Hi @scoutmedic 

 

Download example PBIX file

 

You say you have 1 table but your measure refers to 2 : Error Table and Combined Error Data

 

You are also referring to 3 different columns but you said you have 2 : [Area], [Category] and [Category Detail]

 

If you are using 1 table with 2 columns like like this

 

PhilipTreacy_0-1721695343116.png

 

then this measure will do what you want

 

Errors = CALCULATE(COUNTROWS('Combined Error Data'), FILTER('Combined Error Data', CONTAINSSTRING('Combined Error Data'[Category], "Floor") && (CONTAINSSTRING('Combined Error Data'[Category Detail], "apple") || CONTAINSSTRING('Combined Error Data'[Category Detail], "orange") || CONTAINSSTRING('Combined Error Data'[Category Detail], "grapes") || CONTAINSSTRING('Combined Error Data'[Category Detail], "watermelon"))))

 

PhilipTreacy_1-1721695367715.png

 

 

regards

 

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


View solution in original post

4 REPLIES 4
Ashish_Mathur
Super User
Super User

Hi,

Share some data to work with and show the expected result.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
PhilipTreacy
Super User
Super User

Hi @scoutmedic 

 

Download example PBIX file

 

You say you have 1 table but your measure refers to 2 : Error Table and Combined Error Data

 

You are also referring to 3 different columns but you said you have 2 : [Area], [Category] and [Category Detail]

 

If you are using 1 table with 2 columns like like this

 

PhilipTreacy_0-1721695343116.png

 

then this measure will do what you want

 

Errors = CALCULATE(COUNTROWS('Combined Error Data'), FILTER('Combined Error Data', CONTAINSSTRING('Combined Error Data'[Category], "Floor") && (CONTAINSSTRING('Combined Error Data'[Category Detail], "apple") || CONTAINSSTRING('Combined Error Data'[Category Detail], "orange") || CONTAINSSTRING('Combined Error Data'[Category Detail], "grapes") || CONTAINSSTRING('Combined Error Data'[Category Detail], "watermelon"))))

 

PhilipTreacy_1-1721695367715.png

 

 

regards

 

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Hi Phil,

 

Error Table should be Combined Error Data. Missed renaming that one for the example.

 

You were spot on with the table. There is other fruit on the floor I don't want to count which is why I was going this route. I'll give it a shot and see what happens.

@PhilipTreacy This worked. If I wanted to modify it to look for items in floor and hall that were not apple, orange, or grape?

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.