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
IanGladden
Frequent Visitor

Show 0 as 0 but blanks to stay blank

I am measuring persistent absence for students in our school which is anybody with less than 90% attendance. The issue I have is that some are being returned blank. Now some are blank because they are educated at another establishment although they are on our roll. But a couple are blank because they are school refusers and so don't attend anywhere and I do need them to show as less than 90%. The DAX I use is the below.

 

 

%att = [n_present]/([n_auth_abs]+[n_unauth_abs]+[n_present])

 

 

 Those I need to show, for example, as 0% would have 0/0+120+0 whereas those I need to stay blank would be 0/0+0+0 as they do not need to attend.

If I do the usual

 

 

%att = [n_present]/([n_auth_abs]+[n_unauth_abs]+[n_present])+0

 

 

then those who do not need to attend show as 0% and are then included when I calculate my persistently absent students.

1 REPLY 1
MartynRamsden
Solution Sage
Solution Sage

Hi @IanGladden 

 

Could you check to see if the denominator returns 0 and if so, return blank, otherwise calculate the %?

 

For example:

 

%att =
VAR Denominator = ( [n_auth_abs] + [n_unauth_abs] + [n_present] )
VAR Result =
    IF (
        Denominator = 0,
        BLANK (),
        DIVIDE ( [n_present], Denominator )
    )
RETURN
    Result

 

Note: I've used the DIVIDE function to avoid any divide by zero errors.

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.