Forum Discussion
olivere91
Helper I
3 years agoFormula Not working - Changing measure based on slicer year
I have a formula that should change the measure if the year is not 2023. It returns the measure Margin $ if the year is before 2022, that's great, but if the year is 2023 then Margin $ new should be returned and it's not.
GM Dollars =
SUMX (
VALUES ( Item_Sales_Profit[Customer No.] ),
SWITCH (
TRUE (),
Item_Sales_Profit[Customer No.] = "cus"
&& YEAR(SELECTEDVALUE(Dates[Year])) >= 2023,
[Margin $ New],
Item_Sales_Profit[Customer No.] = "cus"
&& YEAR(SELECTEDVALUE(Dates[Year])) < 2023,
[Margin $],
[GM $]
)
)
1 Reply
- some_bih
Community Champion
Hi olivere91 did you try to "switch" conditions in your measure, like change places of "year" part filter? Switch restrict some results.
Check link https://dax.guide/switch/ (last 2 examples)
Hope this help
GM Dollars =SUMX (VALUES ( Item_Sales_Profit[Customer No.] ),SWITCH (TRUE (),Item_Sales_Profit[Customer No.] = "cus"&& YEAR(SELECTEDVALUE(Dates[Year])) < 2023,[Margin $],Item_Sales_Profit[Customer No.] = "cus"&& YEAR(SELECTEDVALUE(Dates[Year])) >= 2023,[Margin $ New],[GM $]))