Forum Discussion

Nickodemus's avatar
Nickodemus
Helper III
7 years ago
Solved

Use different values in measure dependent on a user defined preference

I have fields in my data as follows: Product Cost A Cost B One 100 110 Two 400 450 Three 300 320 Four 500 575 Five 900 1010   I need to create a report which dis...
  • TomMartens's avatar
    7 years ago

    Hey Nickodemus 

     

    I prefer to create a multi select slicer that contains all the products, for this it's necessary to create a separate table, that is not related to the table that contains the Columns "Cost A" and "Cost B".

     

    Then I created this measure:

    Use Cost B if ticked = 
    var checkIsFiltered = ISFILTERED('Products using Cost B'[Product])
    var theBProducts = VALUES('Products using Cost B'[Product])
    return
    SUMX(
        VALUES('Fact'[Product])
        ,IF(AND(checkIsFiltered , 'Fact'[Product] in theBProducts)
            , CALCULATE(SUM('Fact'[Cost B]))
            , CALCULATE(SUM('Fact'[Cost A]))
        )
    )

    This allows to create something like this:

    Hopefully this is what you are looking for.

     

    Regards,

    Tom