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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
e175429
Helper I
Helper I

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

Top Kudoed Authors