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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
LamSar
Helper III
Helper III

Dynamic gradient color scale - Power BI Matrix

Good morning,

 

I have a specific requirement:

In a Power BI Matrix I need to add a dynamic gradient color scale based on the min and the max sales per Chain & MarginType. 

 

I've managed to create a gradient color scale, based on the min and max sales for all shops, however, I need to have the min and max values per cluster of Chain and Margin Type.

I've used this measure to achieve this:

var a = maxx(ALLSELECTED(Shop[ShopName]),[_Sales])
var b = MINX(ALLSELECTED(Shop[ShopName]),[_Sales])
var range = a-b
var hue = ROUND(
    DIVIDE([_Sales] - b, range)*120, 0)
var color = "hsla(" & hue & ", " & "100%" & ", " & "90%" & ", " & 1 & ")"
return
color
 
For examle:
ShopSales
A

10

B

20

C

30

D

40

 

Shop A and D are the sames chain and MarginType. Min = 10, max = 40

Shop B and C are the same chain and MarginType. Min = 20, max = 30

 

The Matrix contains the shopName in the rows and sales in the values. On the values I need to apply conditional formatting.  

It doesn't matter if only a few shops are selected or all. The color scale should always be the same. 

In this case I would need 2 color scales because I have 2 different clusters. 

So based on the example the coloring should look like this:

LamSar_0-1693472060576.png

Is something like this even possible?

1 REPLY 1
lbendlin
Super User
Super User

yes, background color is controllable via functions.  You can create another measure that computes the desired color for each of your matrix value cells, and use that measure as the driver for the backgroud color.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors