Forum Discussion

Michael_Gold's avatar
Michael_Gold
Frequent Visitor
4 years ago
Solved

Using slicer for a measure

Hello,   I've created a measure called risk_flag that can receive the following values: No risk, low, medium, high Risk_Flag = IF([Gap]>30,"High",IF([Gap]>15,"Medium",IF([Gap]>0,"Low","No risk"))...
  • edhans's avatar
    edhans
    4 years ago

    Here you go Michael_Gold 


    I used this measure. You can see I kept your basic measure but assigned to to the varRiskAssessment variable, then used it in the Result variable.

     

     

    Risk_Flag =
    VAR varSelectedRisk =
        SELECTEDVALUE( 'Risk Slicer'[Risk] )
    VAR varRiskAssessment =
        IF(
            [Gap] > 30,
            "High",
            IF(
                [Gap] > 15,
                "Medium",
                IF(
                    [Gap] > 0,
                    "Low",
                    "No risk"
                )
            )
        )
    VAR Result =
        SWITCH(
            TRUE,
            varSelectedRisk = "High"
                && varRiskAssessment = "High", "High",
            varSelectedRisk = "Medium"
                && varRiskAssessment = "Medium", "Medium",
            varSelectedRisk = "Low"
                && varRiskAssessment = "Low", "Low",
            varSelectedRisk = "No Risk"
                && varRiskAssessment = "No Risk", "No Risk",
            ISBLANK(varSelectedRisk), varRiskAssessment
        )
    RETURN
        Result

     

     

     

    then I set the measure filter on the table visual to hide when Risk_Flag was blank. If you don't do that, then the High/Med/Low will vanish from the Risk Flag, but the record will still show up as blank (though your conditional formats would still be there). I figured hiding the unselected value is what you wanted, thus the measure filter shown below.

     


    The slicer came from a manually entered table. Go to Transform Data and you will see it, and click the Gear icon next to the Source step to edit that table.
    See this PBIX.

    It is a multi-step process, but hopefully you can follow my logic and example. Let me know if you have questions.