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

Measure Incorrect when selecting option in Slicer

Hello All,

 

I have a measure that calculates the % of completed tasks that have achieved SLA, When i use my Slicer to choose "CAT 2 Achieved SLA" it shows correct value, but when i select "CAT 2 Missed SLA" the slicer shows an Incorrect value. I would like the value to show as 0% when anything other than "CAT 2 Achieved SLA" is selected.

 

Thanks in advance!

 

<<<<< PBIX file >>>>> 

 

 

CAT 2 SLA Achieved % = 
var CAT2A=
    CALCULATE(
        COUNT('Master AllCSA-ExternalOPEX'[Is Job within SLA]),
        'Master AllCSA-ExternalOPEX'[Is Job within SLA]="CAT 2 Achieved SLA"
    )
    return
var CAT2AT=
    CALCULATE(
        COUNT('Master AllCSA-ExternalOPEX'[CATEGORY]),
        'Master AllCSA-ExternalOPEX'[CATEGORY]="CAT 2",
        'Master AllCSA-ExternalOPEX'[Status]="Completed"
    )
    return
var CAT2AP=
    CALCULATE(
        (CAT2A/CAT2AT)
    )
    return
    IF(
        ISBLANK(
            CAT2AP),
            "0%",
            IF(
                ISERROR(
                    CAT2AP),
                    "0%",
                    CAT2AP)
                    )

 

 

 

 

Card that shows Measures with incorrect valueCard that shows Measures with incorrect valueTable I created to help identify what the issue may be.Table I created to help identify what the issue may be.SLA Slicer based from a calculated columnSLA Slicer based from a calculated column

4 REPLIES 4
amitchandak
Super User
Super User

@Michael117 , where is code for CAT 2 Missed SLA.

Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

 

May be you leave condition on selected value - selectedvalue(Slicer[slicer])

 

CAT 2 SLA Achieved % = 
var CAT2A=
    CALCULATE(
        COUNT('Master AllCSA-ExternalOPEX'[Is Job within SLA]),
        'Master AllCSA-ExternalOPEX'[Is Job within SLA]=selectedvalue(Slicer[slicer])
    )
    return
var CAT2AT=
    CALCULATE(
        COUNT('Master AllCSA-ExternalOPEX'[CATEGORY]),
        'Master AllCSA-ExternalOPEX'[CATEGORY]="CAT 2",
        'Master AllCSA-ExternalOPEX'[Status]="Completed"
    )
    return
var CAT2AP=
    CALCULATE(
        (CAT2A/CAT2AT)
    )
    return
    IF(
        ISERROR(
            CAT2AP),
            "0%",
            CAT2AP)

 

Hello @amitchandak ,

 

I just tried to add Selectedvalue to the formula and received this error;

 

"A function 'SELECTEDVALUE' has been used in a True/False expression that is used as a table filter expression. This is not allowed."


I'm still working on setting up the test pbix for you. Thanks

@Michael117 , Try in the filter

CAT 2 SLA Achieved % = 
var CAT2A=
    CALCULATE(
        COUNT('Master AllCSA-ExternalOPEX'[Is Job within SLA]),
        filter('Master AllCSA-ExternalOPEX','Master AllCSA-ExternalOPEX'[Is Job within SLA]=selectedvalue(Slicer[slicer]))
    )
    return
var CAT2AT=
    CALCULATE(
        COUNT('Master AllCSA-ExternalOPEX'[CATEGORY]),
        'Master AllCSA-ExternalOPEX'[CATEGORY]="CAT 2",
        'Master AllCSA-ExternalOPEX'[Status]="Completed"
    )
    return
var CAT2AP=
    CALCULATE(
        (CAT2A/CAT2AT)
    )
    return
    IF(
        ISERROR(
            CAT2AP),
            "0%",
            CAT2AP)

Hi @amitchandak ,

 

The filter with selected value didn't achieve the desired outcome. I have added a link to the PBIX file in OP and below;

 

<<<<< PBIX FILE >>>>> 

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.