Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

DAX IF OR Measure not working based on criteria

Hi Experts   I cannot work out whats wrong with the following Measure   Criteria If Worktype = RM and MEUCOMPLIANCEIMPACT = 1  then VAR _A if Worktype = REMST and MEUCOMPLIANCEIMPACT = 0 the ...
  • AllisonKennedy's avatar
    3 years ago

    Anonymous 

     

    You haven't given the Criteria to the IF statement. 

     

    Since you have more than 1 criteria, it may be easier to use a SWITCH:

     

    keep the top part of your measure, but change the RETURN to:

    RETURN

    SWITCH( TRUE(),

    SELECTEDVALUE(Table[Worktype] )= "RM" && SELECTEDVALUE([MEUCOMPLIANCEIMPACT] )= 1  ,  _A, 

    SELECTEDVALUE(Table[Worktype] )= "RMST" && SELECTEDVALUE([MEUCOMPLIANCEIMPACT])  = 0 , _B 

    )

     

    Since it's a measure, you'll need to aggregate the Worktype and MEUCOMPLIANCEIMPACT columns in some way. I chose SELECTEDVALUE, but you could use MAX or SUM depending on how you want it to work.