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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
Anonymous
Not applicable

New measure with switch and selectedvalue to make a colored staircase

Hi,

 

I would like to make a colored staircase according to the different values ​​of my matrix : 

when I have 'public stockview'[end_day_stock]) >= 0, I want the color to be green("#32CD32"),

when I have 'public red_emergency_view'[remaining stock + supply]) >= 0, I want the color to be orange ("#FFA500"),

when I have 'public red_emergency_view'[remaining stock + supply]) < 0, I want the color to be red ("#FF0000")

 

After several attempts, I simplified my conditions by creating a new column on PowerQuery which indicates the color that the line must take according to the conditions above

 

On the PowerBI side, I created a new measure :

color_measure = SWITCH(SELECTEDVALUE('fusion stockview et red_emergency_view'[couleur]), "#32CD32", "#32CD32", "#FFA500", "#FFA500", "#FF0000", "#FF0000")

 

Then, I performed conditional formatting on my "Stock restant" values ​​based on the measure

However this only works if all the values ​​in my row give the same result

- If I have 'public stockview'[end_day_stock]) >= 0 for each cell, everything is green

Morganld_0-1663920227053.png

Same for orange and red

 

However in cases where several cells verify different conditions, there is no color

Morganld_1-1663920255905.png

But according to my conditions, the cells of 23/09, 26/09, 03/10, 06/10, 07/10 and 10/10 should be red and the others orange

Morganld_2-1663920276917.png

 

Thanks for help

1 ACCEPTED SOLUTION
Anonymous
Not applicable

It's works with this measure :

color_mesure = if(SUM('public stockview'[end_day_stock]) >= 0, "#32CD32", if(SUM('public red_emergency_view'[stock restant + appro]) >=0, "#FFA500", "#FF0000"))

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

It's works with this measure :

color_mesure = if(SUM('public stockview'[end_day_stock]) >= 0, "#32CD32", if(SUM('public red_emergency_view'[stock restant + appro]) >=0, "#FFA500", "#FF0000"))

v-rzhou-msft
Community Support
Community Support

Hi @Anonymous ,

 

Here I create a sample to have a test.

RicoZhou_0-1664248949513.png

Measure:

Color = 
VAR _VALUE = SELECTEDVALUE('Table'[Value])
RETURN
IF(_VALUE<0,"Red","Orange")

Use conditional formatting in Matrix. Result is as below.

RicoZhou_1-1664249147184.png

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

Helpful resources

Announcements
Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.