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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
LamSar
Helper III
Helper III

How to create a gradient color scale on one row level in Power BI Matrix

Good afternoon,

 

I have a question concerning conditional formatting in a Matrix.

 

I have the following matrix:

LamSar_0-1673261166385.png

On the rows I have Shop type, Shop, function

On the columns I have Year, month

Values= Measure that calculates the hours

 

The requirement is to have a gradient color scale on the rows of the shops (highlighted in yellow) where green is zero hours and it goes to red for the max hours. 

I tried using this measure:

Color scale =
VAR SummaryTable =
CALCULATETABLE(
ADDCOLUMNS(
SUMMARIZE(Tijd, DatumVerkoop[Jaar], DatumVerkoop[MaandNaam], Shop[Name]), "AantalUren", [_AlleUren Y (U)]),
ALLSELECTED())
Var MaxValue =
MAXX(SummaryTable, [AantalUren])

Var MINXValue =
MINX(SummaryTable, [AantalUren])

VAR Range =  MaxValue - MINXValue
Var Hue = ROUND(DIVIDE([_AlleUren Y (U)] - MINXValue,Range),2)
Var Colour = If(ISFILTERED(Shop[Name]) && [_AlleUren Y (U)] >= MINXValue && [_AlleUren Y (U)] <= MaxValue,"hsla("& Hue & ", " & "100%" & ", " & "90%" & ", " & 1 & ")", blank())

RETURN
Colour
 
But as you can see in the screenshot it only shows a color for the lowest value and the highest value.
I also need to be able to set the colors for zeo hours (green) to max hours red.
The color scale should look something like this:
LamSar_1-1673261534309.png

 

  Any ideas on how to fix this?
1 ACCEPTED SOLUTION
v-shex-msft
Community Support
Community Support

HI @LamSar,

AFAIK, you can’t be accurate to control the detail color in 'color scale' mode.

I’d like to suggest you use measure formula to parameterize the color code with the variable calculation result and use this formula as conditional formatting with expression mode.

For dynamic the colors based on calculation result, you can take a look at the following video about use Dax formula to apply HSLA color to visual if helps:

Advanced Coloring in Power BI For ALL VISUALS using HSLA Colors and DAX - YouTube

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

1 REPLY 1
v-shex-msft
Community Support
Community Support

HI @LamSar,

AFAIK, you can’t be accurate to control the detail color in 'color scale' mode.

I’d like to suggest you use measure formula to parameterize the color code with the variable calculation result and use this formula as conditional formatting with expression mode.

For dynamic the colors based on calculation result, you can take a look at the following video about use Dax formula to apply HSLA color to visual if helps:

Advanced Coloring in Power BI For ALL VISUALS using HSLA Colors and DAX - YouTube

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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