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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
Eric_Fabric
New Member

Format fields in matrix based on dynamic condition

Hello everyone

 

I am trying to conditionally format fields in a matrix, based on their value relative to the other values on the same row. To illustrate, I have created a sample matrix:

Eric_Fabric_1-1710862580936.png

 

The report is for a divison (lets say division "A", represented in the first column) that needs to compare their performance to the other divisions (in the real scenario there are ten total). What is needed in the report is for the matrix to be conditionally formatted, so that the top three values for every row get highlighted, while the rest should not receive any coloring.

 

It is no issue, that only the lowest hierarchy level currently expanded gets highlighted.

In a second step it is required, that these top three values per row should also be used in a separate table to derive an average from them and then compare that value again to the (raw) value of division A.

 

I could not find a way that either of this works, as I didn't get how to implement a threshold for the conditional formatting that adapts to the values per row, which is what I thought might be the solution.
I am open to any recommendation on how to get this done, though I would prefer if no custom visuals had to be used, as this will cause a delay due to a mandatory internal approval process.
However I'd much rather have such a solution than no solution at all.

Thank you very much for any effort in helping me with this problem!

 

Kind regards,

Eric

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Eric_Fabric ,

Below is my table:

vxiandatmsft_0-1710915227308.png

Please apply the following measures to your form background/font color.

Power BI's built-in conditional formatting settings do not directly support directly highlighting the first three values in each row of the matrix.

You can try to use the following dax conditional format, and replace the specific values with the data in your table

Color Measure = 
VAR _loadtime = SUM('Table'[LoadTime])
RETURN
SWITCH(TRUE(),
SELECTEDVALUE('Table'[Page]) = "Homepage" && _loadtime < 7.6, "Green",
SELECTEDVALUE('Table'[Page]) = "FlightSelect" && _loadtime< 15.36, "Green",
SELECTEDVALUE('Table'[Page]) = "Guest" && _loadtime< 14.53, "Green",
SELECTEDVALUE('Table'[Page]) = "Booking Summary" && _loadtime < 34.53 , "Green",
SELECTEDVALUE('Table'[Page]) = "Addons" && _loadtime < 24.43, "Green")

Measure are then created for the average

RankMeasure = RANKX(ALLSELECTED('Table'[Airline]), CALCULATE(SUM('Table'[LoadTime])), , DESC, Dense)




AvgTop3Measure = AVERAGEX(TOPN(3, ALL('Table'), [RankMeasure]), CALCULATE(SUM('Table'[LoadTime])))


The final output is shown in the following figure:

vxiandatmsft_1-1710915449378.png

Best Regards,

Xianda 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 @Eric_Fabric ,

Below is my table:

vxiandatmsft_0-1710915227308.png

Please apply the following measures to your form background/font color.

Power BI's built-in conditional formatting settings do not directly support directly highlighting the first three values in each row of the matrix.

You can try to use the following dax conditional format, and replace the specific values with the data in your table

Color Measure = 
VAR _loadtime = SUM('Table'[LoadTime])
RETURN
SWITCH(TRUE(),
SELECTEDVALUE('Table'[Page]) = "Homepage" && _loadtime < 7.6, "Green",
SELECTEDVALUE('Table'[Page]) = "FlightSelect" && _loadtime< 15.36, "Green",
SELECTEDVALUE('Table'[Page]) = "Guest" && _loadtime< 14.53, "Green",
SELECTEDVALUE('Table'[Page]) = "Booking Summary" && _loadtime < 34.53 , "Green",
SELECTEDVALUE('Table'[Page]) = "Addons" && _loadtime < 24.43, "Green")

Measure are then created for the average

RankMeasure = RANKX(ALLSELECTED('Table'[Airline]), CALCULATE(SUM('Table'[LoadTime])), , DESC, Dense)




AvgTop3Measure = AVERAGEX(TOPN(3, ALL('Table'), [RankMeasure]), CALCULATE(SUM('Table'[LoadTime])))


The final output is shown in the following figure:

vxiandatmsft_1-1710915449378.png

Best Regards,

Xianda 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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Feb2025 NL Carousel

Fabric Community Update - February 2025

Find out what's new and trending in the Fabric community.