Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
reyesdjr
Frequent Visitor

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.

 

Demand Classification =
IF(
    'ItemsOutbound'[Seasonal Demand Index] > 1.2,
    "High Demand",
    IF(
        'ItemsOutbound'[Seasonal Demand Index] >= 0.9,
        "Stable Demand",
        "Low Demand"
    )
)
 
I also tried this:
 
Demand Classification =
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"
)
 
but it still showing stable demand. 
 
Please help, thank you!
 
2 ACCEPTED SOLUTIONS

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]))

 



If the post helped then please give it a Kudos and mark it as the solution so others can see it.
Cheers,

View solution in original post

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-...

- 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.



If the post helped then please give it a Kudos and mark it as the solution so others can see it.
Cheers,

View solution in original post

17 REPLIES 17
reyesdjr
Frequent Visitor

I tried and its still the same.

reyesdjr_0-1728747234187.png

 

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"
)


If the post helped then please give it a Kudos and mark it as the solution so others can see it.
Cheers,

Thank you, I tried but only stable demand is showing.

 

reyesdjr_0-1728748150226.png

 

Please check the formatting of the Demand Index values, they may be Text instead of Decimal numbers.



If the post helped then please give it a Kudos and mark it as the solution so others can see it.
Cheers,

Thank you, there is no text. I did check the data. 

reyesdjr_0-1728748902161.png

 

Do a simple test, create two measures:

DC_1=
IF('ItemsOutbound'[Seasonal Demand Index] > 1, "High Demand","N/A")

DC_2=
IF('ItemsOutbound'[Seasonal Demand Index] > 0, "High Demand","N/A")

 

See which one returns garbage vs the data you have in your column. If both return N/A then there is something wrong with the data.



If the post helped then please give it a Kudos and mark it as the solution so others can see it.
Cheers,

DC1 all N/A and DC2 all high demand. 

reyesdjr_0-1728749617053.png

 

So

'ItemsOutbound'[Seasonal Demand Index] 

is between 0 and 1. Is this a calculated column? Could you please create another test column in the same table with the below formula and screenshot the values?

D_Index_Forum = VALUE([Seasonal Demand Index])


If the post helped then please give it a Kudos and mark it as the solution so others can see it.
Cheers,

Values below: 

reyesdjr_0-1728750589004.png

This is for seasonal deman index: 

Seasonal Demand Index = Divide('SCM ItemsOutbound'[ABS - Custom],('SCM ItemsOutbound'[Average Demand]),0)
 
Thank you 

Could you please creenshot the actual column in the table? Also, how do you Sum the D_Index_Forum values, do you have a measure or you let PowerBI to do it?



If the post helped then please give it a Kudos and mark it as the solution so others can see it.
Cheers,

Thank you, I let PowerBi do the sum. Any specific column for screen capture? I have tons of columns. 

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]))

 



If the post helped then please give it a Kudos and mark it as the solution so others can see it.
Cheers,

Thank you, I created a measure for both seasonal demand index and demand classification and it worked. Question though, since its a measure, I cant add it as a legend using a clustered chart?

You can't add a measure to Legend.

What do you want to add? Which value or information?



If the post helped then please give it a Kudos and mark it as the solution so others can see it.
Cheers,

I want to add demand classification as the legend. 

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-...

- 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.



If the post helped then please give it a Kudos and mark it as the solution so others can see it.
Cheers,
Ahmedx
Super User
Super 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" )
)

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.