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

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

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
Super User
Super User

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
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.