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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
o59393
Post Prodigy
Post Prodigy

Filter data not showing correct results in card

Hi all

 

I created a dax function to calculate the percentage of projects under high risk, medium risk and low risk.

 

The metric works ok when nothing is selected or I select a country for example, however when I use the slicer and filter by the type of risk (high risk, medium or low), the percentages results in the cards make no sense.

 

The table used is:

 

heatmap.png

 

 

heatmap 2.PNG

 

 

heatmap 3.png

What I would like to have is, if i select high risk in the slicer, then 100% of HR in the card and the rest show 0%, if I select medium risk in the slicer, the card should 100% for medium risk and 0% for the rest, and so on.

 

Thanks!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @o59393 ,

You can try to use the following measure formulas:

LR =
IF (
    "Low Risk" IN VALUES ( 'Table'[Risk] ),
    CALCULATE ( COUNT ( 'Table'[Risk] ), 'Table'[Risk] = "Low Risk" )
        / COUNT ( 'Table'[Risk] ),
    0
)
MR = 
IF (
    "Medium Risk" IN VALUES ( 'Table'[Risk] ),
    CALCULATE ( COUNT ( 'Table'[Risk] ), 'Table'[Risk] = "Medium Risk" )
        / COUNT ( 'Table'[Risk] ),
    0
)
HR = 
IF (
    "High Risk" IN VALUES ( 'Table'[Risk] ),
    CALCULATE ( COUNT ( 'Table'[Risk] ), 'Table'[Risk] = "High Risk" )
        / COUNT ( 'Table'[Risk] ),
    0
)

74.gif
Regards,

Xiaoxin Sheng

View solution in original post

10 REPLIES 10
Anonymous
Not applicable

HI @o59393 ,

Can you please share some sample data with your measure formula? It is hard to test without any sample data.

How to Get Your Question Answered Quickly  

In addition, you can try to use the following measure which will dynamic changes based on your selection:

Measure =
CALCULATE ( COUNT ( Heatmap[Risk] ), VALUES ( Heatmap[Risk] ) )
    / COUNT ( Heatmap[Risk] )

Regards,

Xiaoxin Sheng

hi!

 

Here you go the sample data

 

https://www.mediafire.com/file/ipnnoa6ng49gsx6/query_%288%29.xlsx/file

 

I tried that formula and still game me high %, above 100%

 

Thanks 🙂 

Anonymous
Not applicable

Hi @o59393 ,

You can try to use the following measure formulas:

LR =
IF (
    "Low Risk" IN VALUES ( 'Table'[Risk] ),
    CALCULATE ( COUNT ( 'Table'[Risk] ), 'Table'[Risk] = "Low Risk" )
        / COUNT ( 'Table'[Risk] ),
    0
)
MR = 
IF (
    "Medium Risk" IN VALUES ( 'Table'[Risk] ),
    CALCULATE ( COUNT ( 'Table'[Risk] ), 'Table'[Risk] = "Medium Risk" )
        / COUNT ( 'Table'[Risk] ),
    0
)
HR = 
IF (
    "High Risk" IN VALUES ( 'Table'[Risk] ),
    CALCULATE ( COUNT ( 'Table'[Risk] ), 'Table'[Risk] = "High Risk" )
        / COUNT ( 'Table'[Risk] ),
    0
)

74.gif
Regards,

Xiaoxin Sheng

hi!

 

thanks for the help

 

I got an error:

 

The syntax for 'MR' is incorrect. (DAX(IF("Low Risk" IN VALUES(Heatmap[Risk]),CALCULATE(COUNT(Heatmap[Risk]),Heatmap[Risk]="Low Risk")/COUNT(Heatmap[Risk]),0)MR = IF("Medium Risk" IN VALUES(Heatmap[Risk]),CALCULATE(COUNT(Heatmap[Risk]),Heatmap[Risk]="Medium Risk")/COUNT(Heatmap[Risk]),0))).

 

in values.PNG

 

Thanks for the help!

Anonymous
Not applicable

Hi @o59393 ,

In fact, I attached three measures, you need to create three measures fields to stored these formulas.
Regards,

Xiaoxin Sheng

Hi

 

Apologies for my ignorance, how do i create the measure fields? Cant see the attachment.

 

Can you please share how to create them?

 

Thanks!

@Anonymous  I created the DAX with the 3 metrics but I still get the same error. Did you do something additional? Can you please shere the pbi.

 

Thanks!

Anonymous
Not applicable

Hi @o59393 ,

I attached the sample file below, you can try it if it works on your side.

Regards,

Xiaoxin Sheng

lc_finance
Solution Sage
Solution Sage

Hi @o59393 ,

 

 

could you share a sample Power BI file?

That will make it easier to help you

 

LC

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.