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

return 0 when the value is blank

Hi helpful people,

 

I have below measure counting a text field, I need to return 0 when field value is blank, Below is the measure I created.

 

=======

TSF Facility in Use =
VAR Total = CALCULATE(
COUNT('FACT-Data'[TEXT]),
KEEPFILTERS('FACT-Data'[TEXT] <> BLANK())

)
VAR Result = IF(Total = BLANK(), 0, Total)

RETURN
Total
========
itemswithblank.jpg
In the Test M, i need 0 when the count is blank. my formula does not work the way I want when I put if conditions other Matrix names come up in the visual (table). I need only to show the 0 for this selection (as in the tabel)
1 ACCEPTED SOLUTION
Super User II
Super User II

@amalrio 

Try the following:

TSF Facility in Use =
VAR Total = CALCULATE(
COUNT('FACT-Data'[TEXT]),
KEEPFILTERS('FACT-Data'[TEXT] <> BLANK())
)
RETURN
IF(ISBLANK(Total), 0, Total)

 

Another option is to add 0 at the end the formula:

TSF Facility in Use = CALCULATE(
COUNT('FACT-Data'[TEXT]),
KEEPFILTERS('FACT-Data'[TEXT] <> BLANK())
) + 0

________________________


If this post helps, then please Accept it as the solution to help other community members find it more quickly


Click on the Thumbs-Up icon if you like this reply.


Check out my COVID-19 Report in Data Stories Gallery:    COVID-19 Report

View solution in original post

3 REPLIES 3
Super User IV
Super User IV

@amalrio , in the return you can add +0

 

RETURN
Total +0

 

Or

RETURN

if(isblank(Total),0,Total)



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!

Super User I
Super User I

@amalrio 

 

Modify with ISNULL

 

TSF Facility in Use =
VAR Total = CALCULATE(
COUNT('FACT-Data'[TEXT]),
KEEPFILTERS('FACT-Data'[TEXT] <> BLANK())
)
RETURN
IF(OR(ISBLANK(Total),ISNULL(Total)), 0, Total)





If this helps, Appreciate your KUDOS!
Did I answer your question? Mark my post as a solution!


Proud to be a Super User!




Super User II
Super User II

@amalrio 

Try the following:

TSF Facility in Use =
VAR Total = CALCULATE(
COUNT('FACT-Data'[TEXT]),
KEEPFILTERS('FACT-Data'[TEXT] <> BLANK())
)
RETURN
IF(ISBLANK(Total), 0, Total)

 

Another option is to add 0 at the end the formula:

TSF Facility in Use = CALCULATE(
COUNT('FACT-Data'[TEXT]),
KEEPFILTERS('FACT-Data'[TEXT] <> BLANK())
) + 0

________________________


If this post helps, then please Accept it as the solution to help other community members find it more quickly


Click on the Thumbs-Up icon if you like this reply.


Check out my COVID-19 Report in Data Stories Gallery:    COVID-19 Report

View solution in original post

Helpful resources

Announcements
secondImage

Happy New Year from Power BI

This is a must watch for a message from Power BI!

December Update

Check it Out!

Click here to read more about the December 2020 Updates!

Community Blog

Check it Out!

Click here to read the latest blog and learn more about contributing to the Power BI blog!

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