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
amalrio
Helper V
Helper V

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
themistoklis
Community Champion
Community Champion

@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

4 REPLIES 4
RichardElmer
Regular Visitor

+0  So Simple.... Thank you

amitchandak
Super User
Super User

@amalrio , in the return you can add +0

 

RETURN
Total +0

 

Or

RETURN

if(isblank(Total),0,Total)

manikumar34
Solution Sage
Solution Sage

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




themistoklis
Community Champion
Community Champion

@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

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.