Forum Discussion
LucasBW
6 months agoRegular Visitor
Matrix table with dynamic gradient background color when there's hierarchy level
Good day everyone. I'm struggling with a obstacle in Matrix table about having gradient color in a column, when I have hierarchy level row in the table. When I go to Cell Elements > Background an...
cengizhanarslan
6 months agoSuper User
Instead of the built-in Gradient option, drive background color with a measure. For example:
BG Color =
VAR v = [Deposit-Withdrawal]
VAR MinV = CALCULATE ( MIN ( [Deposit-Withdrawal] ), ALLSELECTED ( 'Dim'[Level] ) )
VAR MaxV = CALCULATE ( MAX ( [Deposit-Withdrawal] ), ALLSELECTED ( 'Dim'[Level] ) )
VAR Ratio = DIVIDE ( v - MinV, MaxV - MinV )
RETURN
SWITCH (
TRUE(),
Ratio <= 0.5, "#66CC66",
"#FF9999"
)
Then:
-
Cell Elements → Background color
-
Format by: Field value
-
Based on: BG Color
By the way what danextian is a way more better solution then this as it is more dynamic at the end. But if you want to keep it simple you can stick with this as well with a bit change in the measure depending on your needs.