Search code examples
powerbidaxdata-analysispowerbi-desktopmeasure

ifelse statement in DAX


I am trying to create a calculated column using the code below. Lookup function works find until I added the IF statement above it. What I need is to fix the outcome to 1 when df[col] = "B0" or df[col] = "B1" otherwise outcome should give the lookup function result. how to get around with this ? many thanks in advance.

_FY23_AOP_Rate = 
 IF('df'[col] = "B0" || 'df'[col] = "B1", 
    1, 
    LOOKUPVALUE(
                    dimFX[FY23 AOP], 
                    dimFX[Currency Code], 'df'[Currency])
  
)

Solution

  • Are you just missing an enclosing quote after B1?

    IF('df'[col] = "B0" || 'df'[col] = "B1", 
        1, 
        LOOKUPVALUE(
                        dimFX[FY23 AOP], 
                        dimFX[Currency Code], 'df'[Currency])
      
    )