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
pbiuser12345
Helper I
Helper I

Zero Values For Measure Not Appearing in Matrix Visual

Hello,

 

I have a data set I am trying to summarize using a measure in a matrix visual.  The data is looking at whether certain trains running on time or not, with the data set being records of various trips.  Summarizing the count of trips looks like this:

 

 On TimeLate
Train A9010
Train B75 
Train C5050

 

When I then make use of my measure to summarize the percentage trips that are late, I get this:

 

Train A10%
Train C50%

 

What I really want though is for there to also be a 'Train B' row with 0% in there.  I assume it's because there are no trips that were late and so I'm getting a blank, but various efforts to make it appear (checking for a blank value, adding a 0 to the measure) aren't doing much for me.  The DAX looks like this:

 

 

 

 

% Trips Late = 
    CALCULATE(
        DISTINCTCOUNT('TRAIN_TRIPS'[TRIP_ID]),
        'TRAIN_TRIPS'[LATE_FLAG] = "Late"
    )
    /
    CALCULATE(
        DISTINCTCOUNT('TRAIN_TRIPS'[TRIP_ID]),
        'TRAIN_TRIPS'[LATE_FLAG] IN {"Late", "On Time"}
    )

 

 

 

 

What do I need to do differently to get the table I need?

 

Thanks for your help!

1 ACCEPTED SOLUTION
MohammadLoran25
Super User
Super User

Hi @pbiuser12345 ,

This Solves your problem (need to use DIVIDE function):

 

% Trips Late =
DIVIDE (
    CALCULATE (
        DISTINCTCOUNT ( 'TRAIN_TRIPS'[TRIP_ID] ),
        'TRAIN_TRIPS'[LATE_FLAG] = "Late"
    ),
    CALCULATE (
        DISTINCTCOUNT ( 'TRAIN_TRIPS'[TRIP_ID] ),
        'TRAIN_TRIPS'[LATE_FLAG] IN { "Late", "On Time" }
    )
) + 0

 

 

If this solves your question, Please give it a thumbs up and accept it as a solution to make it easier for the others to find what they are looking for.

Regards,
Loran

 

View solution in original post

1 REPLY 1
MohammadLoran25
Super User
Super User

Hi @pbiuser12345 ,

This Solves your problem (need to use DIVIDE function):

 

% Trips Late =
DIVIDE (
    CALCULATE (
        DISTINCTCOUNT ( 'TRAIN_TRIPS'[TRIP_ID] ),
        'TRAIN_TRIPS'[LATE_FLAG] = "Late"
    ),
    CALCULATE (
        DISTINCTCOUNT ( 'TRAIN_TRIPS'[TRIP_ID] ),
        'TRAIN_TRIPS'[LATE_FLAG] IN { "Late", "On Time" }
    )
) + 0

 

 

If this solves your question, Please give it a thumbs up and accept it as a solution to make it easier for the others to find what they are looking for.

Regards,
Loran

 

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.

Top Solution Authors