Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Nested filtering question

Hello everyone,   I have a currency question. We have a data model that has 3 currencies. Local, Market and USD. I have a measure to display the currency based on the filter selection. It works per...
  • d_gosbell's avatar
    d_gosbell
    7 years ago

    Sorry, I thought they'd updated the IF function to do short circuit evaluation of boolean conditions, but it does not look like it does that (I might be confusing DAX and MDX here), so you'll need to nest the VALUES inside an IF checking for HASONEVALUE.

     

    eg.

     

    Continent Test = 
    VAR local =
        CALCULATE ( SUM ( Sales[sales_amt_local] ) )
    VAR market =
        CALCULATE ( SUM ( Sales[sales_amt_market] ) )
    VAR usd =
        CALCULATE ( SUM ( Sales[sales_amt_usd] ) )
    RETURN
        IF (
            ISFILTERED ( location[cntry_name] ),
            local,
            IF (
                ISFILTERED ( location[mrkt_name] ),
                market,
                IF (
                    IF (HASONEVALUE ( location[cntnt_name] ), VALUES( location[cntnt_name] ), "")  = "EMEA",
                    market,
                    usd
                )
            )
        )