cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper II
Helper II

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

Accepted Solutions
Highlighted
Super User V
Super User V

Re: Count zero but not blank

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
Highlighted
Super User IV
Super User IV

Re: Count zero but not blank

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

 


______________


Has this post solved your problem? Please mark it as a 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.


I work as a trainer and consultant for Microsoft 365, specialising in Power BI and Power Query. 


excelwithallison.com

Highlighted
Super User V
Super User V

Re: Count zero but not blank

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

Highlighted
Super User IX
Super User IX

Re: Count zero but not blank

@seryil , Try

 

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



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Dashboard of My Blogs !! YouTube Channel !! Connect on Linkedin

Proud to be a Super User!

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Upcoming Events

Experience what’s next for Power BI

See the latest Power BI innovations, updates, and demos from the Microsoft Business Applications Launch Event.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Get Ready for Power BI Dev Camp

Get Ready for Power BI Dev Camp

Mark your calendars and join us for our next Power BI Dev Camp!.

Top Solution Authors
Top Kudoed Authors