Using ifelse and list in DAX

Advertisements

I would like to change the sign of _myMeasure when 'dimData'[Column] in var_ list. What I am missing in the code below ? many thanks in advance.

_MySign = 
var _ list = {"AAA", "BBB", "CCC"}
IF(
'dimData'[Column] in _ list,
[_MyMeasure]*-1, 
         [_MyMeasure] 

)

>Solution :

You don’t need to declare _list variable again inside the IF statement.

Assuming this code is for a measure then you need to wrap ‘dimData'[Column] with SELECTEDVALUE.

_MySign =
VAR _list = { "AAA", "BBB", "CCC" }
RETURN
    IF (
        SELECTEDVALUE ( 'dimData'[Column] ) IN _list,
        [_MyMeasure] * -1,
        [_MyMeasure]
    )

Leave a ReplyCancel reply