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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
moses07_ferns
Regular Visitor

Conditional Formatting Matrix Table By Rows

I want to apply conditional formatting row by row based on the value of the measures. For eg. I have three measures 
Measure 1 :- Sales = SUM(Sales_Data[Total Revenue])

Prev Month Sales = CALCULATE([Sales],DATEADD('DATE'[Date],-1,MONTH))
Prev 2MONTHS SALE = CALCULATE([Sales],DATEADD('DATE'[Date],-2,MONTH))

 

The highest value in each row should be green and the lowest value should be red and the mid value should be yellow. Attached file for your reference.  https://drive.google.com/file/d/1YbPJ-K6aamwt1rW1FAqGpnGde6IFd3WB/view?usp=drive_link 

2 ACCEPTED SOLUTIONS
Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I understood your question correctly, but I tried to create three measure that rank three different measures in the table visualization. And then, in the conditional formatting option, I tried to configure like below for all three measures.
Please check the below picture and the attached pbix file.

 

 

Jihwan_Kim_0-1744525460929.png

 

Jihwan_Kim_1-1744525479763.png

 

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

sanalytics
Super User
Super User

Hello @moses07_ferns 

You can follow below approach for your solution as well..
1) One disconnected Measure Table 
2) One Complete Measure.
Below is the code

ColorMatrix = 
VAR _HighestValue = 
MAXX(
 { [Sales],[Prev Month Sales],[Prev 2MONTHS SALE] },
 [Value]
)
VAR _lowestValue = 
MINX(
{[Sales],[Prev Month Sales],[Prev 2MONTHS SALE] },
[Value] )
VAR _MidValue = 
MAXX(
 FILTER(
    { [Sales],[Prev Month Sales],[Prev 2MONTHS SALE] },
 [Value] > _lowestValue && [Value] < _HighestValue
 ),[Value]
)
VAR _result = 
IF(
[MeasureConection] = _HighestValue,
"Green" , IF( [MeasureConection] = _MidValue, "Yellow",
IF( [MeasureConection] = _lowestValue,"Red"
) ) )
RETURN
_result

Below is the screenshot

sanalytics_0-1744629447144.png

pbix file is attached.

 

Hope it helps

 

Regards

sanalytics

 

View solution in original post

6 REPLIES 6
v-ssriganesh
Community Support
Community Support

Hi @moses07_ferns,
I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If my response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.
Thank you.

v-ssriganesh
Community Support
Community Support

Hi @moses07_ferns,

May I ask if you have resolved this issue? If so, please mark it as the solution. This will be helpful for other community members who have similar problems to solve it faster.

Thank you.

sanalytics
Super User
Super User

Hello @moses07_ferns 

You can follow below approach for your solution as well..
1) One disconnected Measure Table 
2) One Complete Measure.
Below is the code

ColorMatrix = 
VAR _HighestValue = 
MAXX(
 { [Sales],[Prev Month Sales],[Prev 2MONTHS SALE] },
 [Value]
)
VAR _lowestValue = 
MINX(
{[Sales],[Prev Month Sales],[Prev 2MONTHS SALE] },
[Value] )
VAR _MidValue = 
MAXX(
 FILTER(
    { [Sales],[Prev Month Sales],[Prev 2MONTHS SALE] },
 [Value] > _lowestValue && [Value] < _HighestValue
 ),[Value]
)
VAR _result = 
IF(
[MeasureConection] = _HighestValue,
"Green" , IF( [MeasureConection] = _MidValue, "Yellow",
IF( [MeasureConection] = _lowestValue,"Red"
) ) )
RETURN
_result

Below is the screenshot

sanalytics_0-1744629447144.png

pbix file is attached.

 

Hope it helps

 

Regards

sanalytics

 

v-ssriganesh
Community Support
Community Support

Hi @moses07_ferns,

Thank you for posting your query in the Microsoft Fabric Community Forum, and thanks to @Jihwan_Kim & @lbendlin for sharing valuable insights.

 

Could you please confirm if your query has been resolved by the provided solution? If so, please mark it as the solution. This will help other community members solve similar problems faster.

Thank you.

 

Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I understood your question correctly, but I tried to create three measure that rank three different measures in the table visualization. And then, in the conditional formatting option, I tried to configure like below for all three measures.
Please check the below picture and the attached pbix file.

 

 

Jihwan_Kim_0-1744525460929.png

 

Jihwan_Kim_1-1744525479763.png

 

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
lbendlin
Super User
Super User

Since you chose to use three measures you will now need to create three more, one for each color calculation. It would have been much easier to use a disconnected calendar table.

 

You made the year and month slicer multi select. That will introduce additional ambiguity.  What should happen when the report user chooses 2020 and 2022, and Apr amd Jun ?

 

Maybe consider graphical solutions instead

 

lbendlin_0-1744473171562.png

 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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