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

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

View solution in original post

Helpful resources

Announcements
secondImage

Congratulations!

We are excited to announce the Power BI Super Users!

Wave Release 2

Check out the updates in Power BI.

Overview of Power BI 2020 release wave 2!

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

secondImage

The largest Power BI virtual conference

100+ sessions, 100+ speakers, Product managers, MVPs, and experts. All about Power BI. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors