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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Count zero but not blank

Hi everyone,

I have created a measure where I count all sales that have been sold with 0 discount. But my problem is that it also counts all the blank fields in the specific column. Below is my measure:

Measure = CALCULATE([Total Sales], Sales[Discount] = 0)

When I write 0 then it takes 0 AND blank. How can I count all the 0 from the column "Discount" but not include blank fields?

1 ACCEPTED SOLUTION
MFelix
Super User
Super User

Hello @seryil ,

You must use the strictly equal sign, so your measure should be:

Measure = CALCULATE([Total Sales], Sales[Discount] == 0)

check the explanation at the following link:

https://dax.guide/op/strictly-equal-to/-:text-Strictly%20equal%20to%20(%3D%3D)%20DAX%20Operator,any%....


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@Anonymous , Try

 

CALCULATE([Total Sales], Filter(Sales,not(isblank(Sales[Discount] )) && Sales[Discount] = 0))
or
CALCULATE([Total Sales], coalesce(Sales[Discount],-1) = 0)

MFelix
Super User
Super User

Hello @seryil ,

You must use the strictly equal sign, so your measure should be:

Measure = CALCULATE([Total Sales], Sales[Discount] == 0)

check the explanation at the following link:

https://dax.guide/op/strictly-equal-to/-:text-Strictly%20equal%20to%20(%3D%3D)%20DAX%20Operator,any%....


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



AllisonKennedy
Super User
Super User

Try countrows on your fact table. use FILTER to filter the fact table for [Discount] <> BLANK() and then count zeros.

Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors