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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Thiago_Sgarbi
Frequent Visitor

Problems with Matrix and Conditional Formatting

Ok, let me try to explain my problem.

 

Thats mt Matrix Table setup,

Rows I set a Group and a Subgroup,
Columns i set a Calculation Group with 8 columns
(Prev Week, Curr. Week, Target, Pre. Month, Curr. Month, Prev. Year, Curr. Year, Delta Target) all calculations with SELECTEDMEASURE() are working fine.
Values 5 Measures. The values are switched to rows an this is what it looks like

Thiago_Sgarbi_1-1723125061259.png

 

So far so good, when I drill the calculations are good.

Now I use 2 Measures to format Background and Font Color

For the Background Measure

 

 

KPI Week Formating Background = 
VAR _measureNamePeriod = SELECTEDVALUE('KPI Week'[Name])
RETURN
SWITCH(TRUE, 
    _measureNamePeriod = "Sett. Corrente", "#E8D166",
    _measureNamePeriod = "Target", "#E6E6E6"
)

 

 

That gets the selected KPI Week[Name] and depending on its text set a background color, the "Sett. Corrente" columns works fine, but the "Target" doesnt change.

Thiago_Sgarbi_2-1723125288861.png

For the Font Color the same problem for the "Delta Target" column
I should evidence the difference from the target

 

 

KPIs Formating Font Color Saturazione = 
VAR _week = MAX(dimCalendar[CurrentWeekOffset])
VAR _year = MAX(dimCalendar[CurrentYearOffset])
VAR _measureNamePeriod = SELECTEDVALUE('KPI Week'[Name])
VAR _targetSaturazione = [Trg](dimTarget[MopCategoriaTarget_Description] = "Saturazione")
VAR _saturazioneWeek = [Saturazione](REMOVEFILTERS(dimCalendar), dimCalendar[CurrentWeekOffset] = _week)
VAR _saturazioneYear = [Saturazione](REMOVEFILTERS(dimCalendar), dimCalendar[CurrentYearOffset] = _year && dimCalendar[CurrentWeekOffset] <= _week)
VAR _currentWeekColName = {"Sett. Corrente", "Mese Corrente", "Anno Corrente"}
VAR _deltaYearColName = { "Delta Target" }
RETURN 
SWITCH(TRUE,
    _measureNamePeriod IN _currentWeekColName && _targetSaturazione > 0 &&
        _saturazioneWeek > _targetSaturazione, "#118D11",
    _measureNamePeriod IN _currentWeekColName && _targetSaturazione > 0 &&
        _saturazioneWeek < _targetSaturazione, "#E66C37",
    _measureNamePeriod IN _deltaYearColName && _targetSaturazione > 0 &&
        _saturazioneYear > _targetSaturazione, "#118D11",
    _measureNamePeriod IN _deltaYearColName && _targetSaturazione > 0 &&
        _saturazioneYear < _targetSaturazione, "#E66C37"
)

 

 

At the previous image you can see "Set. Corrente", "Mese Corrente" and "Anno Corrente" correctly colored but "Delta Target" doesn't change. 

 

Can you help me?

Thank you.

2 REPLIES 2
vanessafvg
Community Champion
Community Champion

are you able to share your model?  if not you need to test to see what it is returning to make sure its doing what you expect.  also validate the hex codes are correct and giving you thee colour you want.

 

 

 





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




ty for your reply, just in case, even if I set the backgound measure hardcoded a color withouth checking column names, all the columns but target and delta target are colored, the same fore Font Color

 

Thiago_Sgarbi_0-1723189252367.png

 

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.