Forum Discussion
Switch or If Function
Hello,
I am using this dax but its not working, its only showing stable demand and not low demand or high demand and I have data from 2020 to 2024.
SWITCH(
TRUE(),
'ItemsOutbound'[Seasonal Demand Index] > 1.2, "High Demand",
'ItemsOutbound'[Seasonal Demand Index] >= 0.9 && 'SCM ItemsOutbound'[Seasonal Demand Index] <= 1.2, "Stable Demand",
'ItemsOutbound'[Seasonal Demand Index] < 0.9, "Low Demand"
)
The D_Index_Forum and the Seasonal Demand Index.
And the classification (your original request) do you do it on the sum of the values on the Seasonal Demand Index?
Instead of letting PowerBI to sum the values, please create a simple measure like this:
Total Demand Index = CALCULATE (SUM([Seasonal Demand Index]))You can do it either via a calculated column or a table to Legend.
Since this is a different topic I suggest you close this thread and do some digging first.
These may help:
- https://community.fabric.microsoft.com/t5/Desktop/How-can-I-plot-my-DAX-measure-as-a-legend-as-well-as-values/m-p/2423682#M867725- https://www.reddit.com/r/PowerBI/comments/13gpo7m/is_there_a_way_to_use_a_measure_as_legend_on_a/
- https://community.fabric.microsoft.com/t5/Desktop/Use-measure-as-chart-legend/m-p/1237315#M547738
Hope it helps.
17 Replies
- AhmedxSuper User
pls try this
Demand Classification = IF('ItemsOutbound'[Seasonal Demand Index] < 0.9, "Low Demand", IF('ItemsOutbound'[Seasonal Demand Index] <= 1.2,"Stable Demand","High Demand" ) ) - reyesdjrFrequent Visitor
I tried and its still the same.
- MNedixSolution Sage
Heya,
In the Switch function, don't bother with the mid value, go for something like this:
Demand Classification = SWITCH( TRUE(), 'ItemsOutbound'[Seasonal Demand Index] > 1.2, "High Demand", 'ItemsOutbound'[Seasonal Demand Index] < 0.9, "Low Demand", "Stable Demand" )- reyesdjrFrequent Visitor
Thank you, I tried but only stable demand is showing.