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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
AnthNC
Helper II
Helper II

Percentage calculation with missing data

Hi everyone,

Could you help me with this problem please :

 

I'm showing in a bar graph the percentage of people who drive wagons, vans and suv, like so :

AnthNC_0-1722489735689.png

 

The data is from a survey in which the item "van" was added after 2021.

If i don't select a year in the slicer "year", the results for "van" can be misinterpreted as "24% of the 9968 people drive a van", which is not representative since the question wasn't asked prior to 2022.

 

Would you know a way to solve this problem ?

I thought about showing two graphs : one with the data from 2018 to 2021, and another one with the following years...

 

Here's the link :

pbix forum2 

 

Thank you for your advice

 

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @AnthNC ,

@raji_n  said adding the year to the x-axis is one way.
And @AnthNC you can also try this, put the field Year into the small multiples:

vjunyantmsft_0-1722584893821.png

vjunyantmsft_1-1722584908487.png


Or you can use this DAX to create a measure:

 

Measure = 
IF(
    NOT ISFILTERED('table1 vehicles'[Year]),
    IF(
        MAX('table1 vehicles'[Attribut]) = "Van",
        "After 2022",
        BLANK()
    ),
    BLANK()
)

 


Place this measure in Data labels > Details:

vjunyantmsft_2-1722585387198.png

Then the "After 2022" field will appear in the Data label:

vjunyantmsft_6-1722585668078.png

I changed the color and font size.

And this will not affect the visual effect after you select the slicer:

vjunyantmsft_4-1722585516577.png

vjunyantmsft_5-1722585523653.png

Best Regards,
Dino Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
AnthNC
Helper II
Helper II

Thank you very much guys

Anonymous
Not applicable

Hi @AnthNC ,

@raji_n  said adding the year to the x-axis is one way.
And @AnthNC you can also try this, put the field Year into the small multiples:

vjunyantmsft_0-1722584893821.png

vjunyantmsft_1-1722584908487.png


Or you can use this DAX to create a measure:

 

Measure = 
IF(
    NOT ISFILTERED('table1 vehicles'[Year]),
    IF(
        MAX('table1 vehicles'[Attribut]) = "Van",
        "After 2022",
        BLANK()
    ),
    BLANK()
)

 


Place this measure in Data labels > Details:

vjunyantmsft_2-1722585387198.png

Then the "After 2022" field will appear in the Data label:

vjunyantmsft_6-1722585668078.png

I changed the color and font size.

And this will not affect the visual effect after you select the slicer:

vjunyantmsft_4-1722585516577.png

vjunyantmsft_5-1722585523653.png

Best Regards,
Dino Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

raji_n
Resolver I
Resolver I

@AnthNC pleaase refer my screenshot earlier, where I have added the year in the x axis, thats one way to represent.

raji_n
Resolver I
Resolver I

Values are appearing correct when I checked the pbix file,

look at the graphs below, the numerator and denominator are dividing properly and the reason why you see van in the bar is because by default the when nothing is selected in the year slicer, all the data is shown.

raji_n_0-1722491488858.png

 

thank you @raji_n 

The calculation is correct, this is not a problem.

 

I am just asking if you guys know a way to show somehow that the 24% corresponding to van drivers (if no years are selected in the slicer) are only representative of the people who were interviewed from 2022 to today...

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors