Forum Discussion
rnola16
1 year agoAdvocate II
Sum on Case Statement on a column
I'm trying to use this SQL statement in DAX func. =Sum( CASE when tablename.colname in ('a','b') then -1 when tablename.colname in ('c','d') then 0 w...
- 1 year ago
Works for me
maybe you are trying to use DAX code in M (Power Query) then it will throw an error on 'in' ? if that's the case then DAX functions cannot be used in M query
Thaumaturgist
1 year agoHelper I
I'd recommend SWITCH. Give this a try:
SUMX(
tablename,
SWITCH(
TRUE(),
tablename[colname] IN {"a", "b"}, -1,
tablename[colname] IN {"c", "d"}, 0,
tablename[colname] IN {"e", "f"}, 1,
0
)
)