Forum Discussion
andytmcc
3 years agoHelper I
Add a Filter to a Switch
I have created a column that assigns a value (0, 0.5 or 1) based on the difference between 2 other columns:
locusofcontrol = SWITCH(
TRUE(),
'Loneliness All Data'[Locus Of Control Mean] > 'Loneliness All Data'[Locusofcontrol Previous Year],1,
'Loneliness All Data'[Locus Of Control Mean] = 'Loneliness All Data'[Locusofcontrol Previous Year],0.5,
0)
However, I only want these values to be created when the value "PC" is in the "Variable" column. How do I add the filter part into this DAX code?
- Anonymous3 years ago
Hi,
Try like this
test_switch = switch(True(),and('Table'[Product]=1,'Table'[Serial Number]=99),1,and('Table'[Product]=1,'Table'[Serial Number]<>99),2,0)
2 Replies
- Greg_DecklerCommunity Champion
andytmcc Maybe:
locusofcontrol = SWITCH( TRUE(), MAX('Loneliness All Data'[PC]) = "Variable" && 'Loneliness All Data'[Locus Of Control Mean] > 'Loneliness All Data'[Locusofcontrol Previous Year],1, MAX('Loneliness All Data'[PC]) = "Variable" && 'Loneliness All Data'[Locus Of Control Mean] = 'Loneliness All Data'[Locusofcontrol Previous Year],0.5, 0) - AnonymousNot applicable
Hi,
Try like this
test_switch = switch(True(),and('Table'[Product]=1,'Table'[Serial Number]=99),1,and('Table'[Product]=1,'Table'[Serial Number]<>99),2,0)