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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Brad333
New Member

CountIf with multiple filters

Hi,

 

Im trying to create a countif in DAX with multiple criteria below is an example, it works when I have the first section but the minute I add the && is shows zero results, im guessing im way off the mark on how to do this, thanks in advance

 

AppTest = CALCULATE(COUNT('app'[app_phase]),
FILTER(ALL('app'), [app_phase] = "complete"
&& [app_phase] = "almost complete"
&& [app_phase] = "delayed"
&& [app_phase] = "restarted"))

 

1 ACCEPTED SOLUTION
Mikelytics
Resident Rockstar
Resident Rockstar

Hi @Brad333 

 

The Problem is that you use an AND condition. What you are doing is you filter a table by checking whether a line has in column [app_phase] the values 

complete" AND

"almost complete" AND

"delayed" AND

"restarted"

 

But since each line can in a column only have one value your if-check everytime returns FALSE which ends in an empty table. I am pretty sure that you need to use || instead of && because || is an OR condition. This means for each line itr will be checked in column [app_phase] has one of the four values and not all together.

 

So please try:

AppTest = CALCULATE(COUNT('app'[app_phase]),
FILTER(ALL('app'), [app_phase] = "complete"
|| [app_phase] = "almost complete"
|| [app_phase] = "delayed"
|| [app_phase] = "restarted"))

 

Best regards
Michael
-----------------------------------------------------
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Appreciate your thumbs up!
@ me in replies or I'll lose your thread.

 

------------------------------------------------------------------
Visit my blog datenhungrig which I recently started with content about business intelligence and Power BI in German and English or follow me on LinkedIn!

View solution in original post

1 REPLY 1
Mikelytics
Resident Rockstar
Resident Rockstar

Hi @Brad333 

 

The Problem is that you use an AND condition. What you are doing is you filter a table by checking whether a line has in column [app_phase] the values 

complete" AND

"almost complete" AND

"delayed" AND

"restarted"

 

But since each line can in a column only have one value your if-check everytime returns FALSE which ends in an empty table. I am pretty sure that you need to use || instead of && because || is an OR condition. This means for each line itr will be checked in column [app_phase] has one of the four values and not all together.

 

So please try:

AppTest = CALCULATE(COUNT('app'[app_phase]),
FILTER(ALL('app'), [app_phase] = "complete"
|| [app_phase] = "almost complete"
|| [app_phase] = "delayed"
|| [app_phase] = "restarted"))

 

Best regards
Michael
-----------------------------------------------------
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Appreciate your thumbs up!
@ me in replies or I'll lose your thread.

 

------------------------------------------------------------------
Visit my blog datenhungrig which I recently started with content about business intelligence and Power BI in German and English or follow me on LinkedIn!

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.