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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
e175429
Helper IV
Helper IV

Need my KPI card to say 0 instead of "Blank"

This is what I want to say:

"How many Administrative are Men?"

This is my DAX: 

M Administrative Associate = CALCULATE([Total Employees], FILTER(cleaned,cleaned[Position Descr] = "ADMINISTRATIVE ASSOCIATE"), FILTER(cleaned,cleaned[Sex] = "M")
And that works fine.
 
HOWEVER, since there are no males in this group I get "Blank" on the KPI card. I need it to just say 0, the actual number instead of blank.
This is my DAX:
M Administrative Associate = IF(ISBLANK(CALCULATE([Total Employees],
                                                  FILTER(cleaned,cleaned[Position Descr] = "ADMINISTRATIVE ASSOCIATE"),                                                                                                FILTER(cleaned,cleaned[Sex] = "M"), 0,
                                                       CALCULATE([Total Employees], FILTER(cleaned,cleaned[Position Descr] = "ADMINISTRATIVE ASSOCIATE"), FILTER(cleaned,cleaned[Sex] = "M")))))
 
And of course this is not working because I suck at DAX 😞

 

1 ACCEPTED SOLUTION

Sorry to be confusing.  VAR1 & VAR2 are just ideas that represent 2 different variables. 

You can call them whatever you want. 

 

- VAR1 contains your original CALCULATE statement (but only 1 time).

- VAR2 contains IF logic that checks to see if VAR1 is blank.

   - IF VAR1 is blank THEN return 0 ELSE return VAR1.

 

 

Take3_0-1690569497324.png

 

View solution in original post

4 REPLIES 4
Take3
Regular Visitor

@e175429 

 

Please try the following.

Place your measure inside of VAR1.

Then create a second VAR2 that checks if VAR1 is blank, and returns 0 if it's blank.

Something like the following.

 

Take3_1-1690561552513.png

 

 

Hope this is helpful to you.

 

Regards,

Nathan

 

P.S.  Although it is possible to go the route you wrote it, it is not recommended.  Both for performance & readability, any time you repeat the same code multiple times within the same measure, it is best practice to place that code inside a VAR.  (In the code below, the exact same CALCULATE appears twice.)

 

Take3_0-1690561921447.png

 

Hey,

 

I am not sure what "Result" should be in VAR2

Sorry to be confusing.  VAR1 & VAR2 are just ideas that represent 2 different variables. 

You can call them whatever you want. 

 

- VAR1 contains your original CALCULATE statement (but only 1 time).

- VAR2 contains IF logic that checks to see if VAR1 is blank.

   - IF VAR1 is blank THEN return 0 ELSE return VAR1.

 

 

Take3_0-1690569497324.png

 

No, you're not confusing, I just don't know what I'm doing. I just started using this service.

 

However, your advice worked so I am very appreciative to you. Thank you so much!

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.