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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
antongg7
Frequent Visitor

Color formatting for matrix with hierarchy levels

I have a matrix visual like in the image and it has different hierarchy levels: 

antongg7_0-1719917853950.png

 

I need the matrix to have this background colours for each group. But I need it to continue having thebackground colours even when I open one of the next level groups. And for example if I open the group "VENTAS" (in green) it just shows the colours for the groups that are open in the same level: 

 

antongg7_1-1719918350161.png

 

In this example, I would still need for the previous level groups to show the colour, for example "APROVISIONAMIENTO" should still be showed in red. But it just shows it if I open that group as well: 

antongg7_2-1719918499263.png

 

The DAX I am using now is: 

Color Cuenta de Expotación =
VAR _conceptoDesc = SELECTEDVALUE('P&G - Jerarquía'[DESCRIPCION])
VAR _conceptoN1 = SELECTEDVALUE('P&G - Jerarquía'[NIVEL 1])
VAR _conceptoN2 = SELECTEDVALUE('P&G - Jerarquía'[NIVEL 2])
VAR _concepto = IF (ISBLANK(_conceptoDesc),IF(ISBLANK(_conceptoN1),_conceptoN2,_conceptoN1),_conceptoDesc)

RETURN
    SWITCH (
        TRUE (),
        _conceptoN1 = "APROVISIONAMIENTO", "rgb(245,138,120)",
        _conceptoN1 = "PERSONAL", "rgb(255,195,122)",
        _conceptoN1 = "ALQUILERES", "rgb(255,230,155)",
        _conceptoN1 = "MANTENIMIENTO", "rgb(255,230,155)",
        _conceptoN1 = "DIGITAL", "rgb(255,230,155)",
        _conceptoN1 = "BANCARIO", "rgb(255,230,155)",
        _conceptoN1 = "TRANSPORTE", "rgb(255,230,155)",
        _conceptoN1 = "OTROS GTOS.", "rgb(255,230,155)",
        _conceptoN1 = "MARKETING", "rgb(255,202,202)",
        _conceptoN1 = "VENTAS", "rgb(198,224,177)",
        _concepto = "GASTOS", "rgb(245,138,120)",
        _concepto = "EBITDA", "rgb(158,192,227)",
        _concepto = "AMORTIZACIONES", "rgb(158,192,227)",
        _concepto = "BENEFICIO ANTES DE IMPUESTOS", "rgb(158,192,227)"
    )
 
 
Is there a way to keep showing the background color for various levels of the hierarchy and not just one of the levels? 
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @antongg7 ,

 

According to your description, here are my steps you can follow as a solution.

(1) We can create a measure. 

Color = SWITCH(TRUE(),
ISINSCOPE('P&G - Jerarquía'[DESCRIPCION]) && MAX('P&G - Jerarquía'[DESCRIPCION])="a","red",
ISINSCOPE('P&G - Jerarquía'[DESCRIPCION]) && MAX('P&G - Jerarquía'[DESCRIPCION])="b","yellow"
)

(2) Then the result is as follows.

vtangjiemsft_0-1719974157818.png

 

 

Best Regards,

Neeko Tang

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

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi @antongg7 ,

 

According to your description, here are my steps you can follow as a solution.

(1) We can create a measure. 

Color = SWITCH(TRUE(),
ISINSCOPE('P&G - Jerarquía'[DESCRIPCION]) && MAX('P&G - Jerarquía'[DESCRIPCION])="a","red",
ISINSCOPE('P&G - Jerarquía'[DESCRIPCION]) && MAX('P&G - Jerarquía'[DESCRIPCION])="b","yellow"
)

(2) Then the result is as follows.

vtangjiemsft_0-1719974157818.png

 

 

Best Regards,

Neeko Tang

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

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.