Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

If selection based on slicer

Hi Everyone,

I'm trying to figure this one out and as a newbie and knowing little with PowerBi I'm not sure where to start.

I want to create a measure that says that if the slicer that the user selects is "Shop A" then I want "table c" to show values for "ShopAB", else if the slicer is anything else other than "Shop A" eg "Shop B" I want "table c" to show values for "Shop B" and if the slicer selected is "Shop C", then "table c" should show "Shop C" etc...the only one that has to be any different is the first one...ie. If the slicer selection is "shop a", table c should show "shop ab"

  • Hi Anonymous ,

    According to your description, I created an example of this. Hope this helps.

    1. Create a Slicer Table which is independent of the other table. 

    Slicer Table = VALUES(Shop[Shop])

    Or, you can just use "Enter Data".

    2. Create a measure.

    Value Measure = 
    VAR SelectedValue =
        SELECTEDVALUE ( 'Slicer Table'[Shop] )
    VAR CurrentValue =
        MAX ( Shop[Shop] )
    RETURN
        IF (
            ISBLANK ( SelectedValue ),
            SUM ( Shop[Value] ),
            IF (
                SelectedValue = "A",
                CALCULATE (
                    SUM ( Shop[Value] ),
                    FILTER ( Shop, Shop[Shop] = "A" || Shop[Shop] = "B" )
                ),
                IF (
                    SelectedValue = CurrentValue,
                    CALCULATE ( SUM ( Shop[Value] ), FILTER ( Shop, Shop[Shop] = CurrentValue ) )
                )
            )
        )

    Then, you can get this:

     

    Best Regards,

    Icey

     

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

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    You can use the SELECTEDVALUE DAX formula to use which Shop is selected in your filter. 

    Your dax formula would look something like 

    yourMeasure = IF(SELECTEDVALUE('table'[SHOPNAME]) = "Shop A", ResultIfTrue, ResultIfNotTrue)

  • Icey's avatar
    Icey
    Community Support

    Hi Anonymous ,

    According to your description, I created an example of this. Hope this helps.

    1. Create a Slicer Table which is independent of the other table. 

    Slicer Table = VALUES(Shop[Shop])

    Or, you can just use "Enter Data".

    2. Create a measure.

    Value Measure = 
    VAR SelectedValue =
        SELECTEDVALUE ( 'Slicer Table'[Shop] )
    VAR CurrentValue =
        MAX ( Shop[Shop] )
    RETURN
        IF (
            ISBLANK ( SelectedValue ),
            SUM ( Shop[Value] ),
            IF (
                SelectedValue = "A",
                CALCULATE (
                    SUM ( Shop[Value] ),
                    FILTER ( Shop, Shop[Shop] = "A" || Shop[Shop] = "B" )
                ),
                IF (
                    SelectedValue = CurrentValue,
                    CALCULATE ( SUM ( Shop[Value] ), FILTER ( Shop, Shop[Shop] = CurrentValue ) )
                )
            )
        )

    Then, you can get this:

     

    Best Regards,

    Icey

     

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