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

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

Reply
StoryofData
Helper III
Helper III

CountIf Multiple Columns

I need to combine two columns IF the other two equal to values I specified, it doesn't calculate properly, I am assuming this is due to &&, I tried || instead but it's still incorrect. What I am doing wrong? 

=

IF('Table'[Column A] = "Subject"
 &&'Table'[Column B] = "Substantiated"
 &&'Table' [Column B] = "Unsubstantiated",
 &&'Table' [Column B] = "Insufficient Data"),
COMBINEVALUES ("-", [Column C], [Column D], BLANK ()))
1 ACCEPTED SOLUTION
PhilipTreacy
Super User
Super User

Hi @StoryofData 

 

Download example PBIX file

 

You can write this 

 

Result = IF([Col A] = "Subject" && ([Col B] = "Substantiated" || [Col B] = "Unsubstantiated" || [Col B] = "Insufficient Data"), [Col D]&"-"&[Col C])

 

 

But when you have multiple options to match for an OR condition you can also use the IN function which is a little neater

 

Result = IF([Col A] = "Subject" && ([Col B] IN {"Substantiated" , "Unsubstantiated" , "Insufficient Data"}), [Col D]&"-"&[Col C])

 

 

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

5 REPLIES 5
PhilipTreacy
Super User
Super User

Hi @StoryofData 

 

Download example PBIX file

 

You can write this 

 

Result = IF([Col A] = "Subject" && ([Col B] = "Substantiated" || [Col B] = "Unsubstantiated" || [Col B] = "Insufficient Data"), [Col D]&"-"&[Col C])

 

 

But when you have multiple options to match for an OR condition you can also use the IN function which is a little neater

 

Result = IF([Col A] = "Subject" && ([Col B] IN {"Substantiated" , "Unsubstantiated" , "Insufficient Data"}), [Col D]&"-"&[Col C])

 

 

rescol.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!


Follow up question Philip, the syntax works fine if it's in table format, however when I try to do a distinct count on it, the number is uncorrect in my screen shot below, distinct count should 5

StoryofData_2-1680189793047.png

 

All Subjects (Participant Closed) =
IF('Table'[IemRoleInCase] = "Subject"
&& ('Table'[IemOutcome] = "Unsubstantiated"
|| 'Table'[IemOutcome] = "Substantiated"
|| 'Table'[IemOutcome] = "Insufficient Data"),
[IemCaseNumber]&" - "&[EmplId])

Thank you

PhilipTreacy
Super User
Super User

Hi @StoryofData 

 

Your formula is testing for 3 different values in [Column B] but it can't have 3 different values.  Because you are using && this situation isn't possible.

 

If you use || then that would be possible for [Column B] to have one of those 3 values. So if you have used || and still aren't getting the results you expect I'd need to see your data and the result of the formula to understand what is going wrong.

 

Can you please supply some data so I can understand exactly what it is you are trying to achieve.

 

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!


StoryofData_1-1680045091273.png

 

Hey, thank you for helping me, my condition is:
Column A = Subject AND

Column B = Substantiated OR Unsubstantiated OR Insufficient Data then combine C and D columns

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.

Top Solution Authors
Top Kudoed Authors