Forum Discussion
DAX IF OR Measure not working based on criteria
- 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.
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.
Hi Allison - firstly thanks for looking at the question but i am getting a blank as th end result when a value is expected
fUll measure
- AllisonKennedy3 years ago
Community Champion
Anonymous What visual context are you trying to use this in? Try changing the SELECTEDVALUE to max and see if that gives you a result, then you need to understand what that is doing as it may not be what you want (which is why I chose SELECTEDVALUE as I find it better to give blank than an incorrect / misleading result).
You need to make sure that you're using WorkTYPE and MEUCOMPLINCEIMPACT columns in the visual where you're using this measure.
If that still doesn't help, please provide more sample data and include the Date column and any relationships.
- Anonymous3 years agoNot applicable
Card visual
- Anonymous3 years agoNot applicable
Hi
No luck with the max and here is the sample data
Sample Data
Count Worktype Status MEUCOMPLIANCEIMPACT 1 RW PPM 0 1 RW PPM 0 1 RW PPM 0 1 RW PPM 0 1 REMST PPM 0 1 REMST PPM 0 1 REMST PPM 0 1 REMST PPM 0
- AllisonKennedy3 years ago
Community Champion
Anonymous
That doesn't look like the raw data, as there are no dates and the 'count' should be a measure, but if you want to use it in a card you need to provide the context within the measure.
Try this:
Remedial Tasks =VAR _A = CALCULATE(COUNTROWS(apple1111),FILTER(apple1111,apple1111[WORKTYPE] = "RW" && apple1111[MEUCOMPLIANCEIMPACT] = 1),apple1111[STATUS] <> "CAN",ALL(DimDates[Date]))
VAR _B = CALCULATE(COUNTROWS(apple1111),FILTER(apple1111,apple1111[WORKTYPE] = "REMST"),apple1111[STATUS] <> "CAN",ALL(DimDates[Date]))RETURNSUMX(apple1111,SWITCH( TRUE(),
apple1111[WORKTYPE] = "RM" && apple1111[MEUCOMPLIANCEIMPACT] = 1 , _A,
apple1111[WORKTYPE] = "REMST" && apple1111[MEUCOMPLIANCEIMPACT] = 0 , _B
))But can you explain in English what you you want as I think we can optimize this for you better.