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
whenriques
Helper I
Helper I

Conditional Formatting in a Matrix with Multiple Levels

Do you happen to know how to use conditional formatting to highlight the highest monthly value? See below:

 

whenriques_0-1660769294113.png

 

I tried the DAX measure below:

 

whenriques_1-1660769294116.png

 

Then, going to conditional formatting and using the following:

 

whenriques_3-1660769294133.png

 

I modified the DAX to use just Year and it works, but the challenge is when I put Month and Year on the same matrix.

 

whenriques_4-1660769443876.png

 

Do you have any ideas or thoughts?

 

Thanks in advance for taking a look at it. I appreciate your time and effort.

 

Cheers,

 

Willer

1 ACCEPTED SOLUTION

Does the below work for you? I think the piece you are missing is that you do want to still filter by years, which you can accomplish by adding VALUES( Date[Year] ) as a filter argument of CALCULATE. The ALLSELECTED was making it so all filters from Date were getting removed. E.g.

MaxInRowContMargin = 
VAR __MaxUnits =
CALCULATE( 
    MAXX( SUMMARIZE( 'Date', 'Date'[Year], 'Date'[Month] ), [ContMargin] ),
    REMOVEFILTERS( 'Date' ), VALUES( 'Date'[Year] ) 
)
RETURN
IF(
    [ContMargin] = __MaxUnits,
    "Light Blue"
)

Note that I summarized Date by Year and Month columns, but I believe the above should work with your VALUES( [Month Year] ) instead of a summarize, too.

View solution in original post

5 REPLIES 5
amitchandak
Super User
Super User

@whenriques , Change _MaxUnits like

 

var _MaxUnits = calculate (

maxx(values( Date[Month Year]), [ContMargin]) , allselected() )

 

or

 

 

var _MaxUnits = calculate (

maxx(values( Date[Month Year]), [ContMargin]) , allselected( Date[Year]) )

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Also, I wanted to mention that the matrix has the values switch to rows under Format visual. Is that what might be causing the problem? See below:

 

whenriques_0-1660858327948.png

Thanks again for your help!

Thank you so much for your response @amitchandak . By using the recommended DAX, It highlighted the highest value of all years and months.

 

whenriques_1-1660856049128.png

 

whenriques_2-1660856446383.png

Currently, I have 'Date'[Year] as rows and 'Date'[Month Name] as columns. The goal is to highlight the highest 'Date'[Month Name] of every year. Seems that we are so close... Do you have any thoughts or suggestions?

 

I appreciate your time and effort!

 

Regards,

 

Willer

Does the below work for you? I think the piece you are missing is that you do want to still filter by years, which you can accomplish by adding VALUES( Date[Year] ) as a filter argument of CALCULATE. The ALLSELECTED was making it so all filters from Date were getting removed. E.g.

MaxInRowContMargin = 
VAR __MaxUnits =
CALCULATE( 
    MAXX( SUMMARIZE( 'Date', 'Date'[Year], 'Date'[Month] ), [ContMargin] ),
    REMOVEFILTERS( 'Date' ), VALUES( 'Date'[Year] ) 
)
RETURN
IF(
    [ContMargin] = __MaxUnits,
    "Light Blue"
)

Note that I summarized Date by Year and Month columns, but I believe the above should work with your VALUES( [Month Year] ) instead of a summarize, too.

That worked like a charm! Thank you so much for your help. Your support is very appreciated!!!

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.