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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
ferk_23
Frequent Visitor

Conditional formatting on matrix table

Hi everyone, 

Untitled.png
I have a similar matrix table to this one. I'm using KPI Name and Version as rows, and Month as a column. I want to do conditional formatting on the column month. I want to put a background color with this condition: I need to compare the two versions (A and B) for each KPI Name. So it's going to be something like (but it's not working):

IF((CALCULATE(SUM(Table[Month]), Table[Version]="A", Table[KPI Name]="Safety")) >= (CALCULATE(SUM(Table[Month]),Table[Version]="T", Table[KPI Name]="Safety")), "#1AAB40", "#D64554")

If something can give me a hint, I would really appreciate that.

Best regards,
Fernando
1 ACCEPTED SOLUTION
v-tangjie-msft
Community Support
Community Support

Hi @ferk_23 ,

 

According to your description, KPI Name and Version as rows and Month as columns are used, and conditional formatting on rows is not supported by design. It is recommended that you create a table visual object.

(1)This is my test data.  

vtangjiemsft_0-1699252312140.png

(2)We can create a measure.

color = 
var _a=CALCULATE(SUM('Table'[Month]),FILTER(ALL('Table'),'Table'[KPI Name]=MAX('Table'[KPI Name]) && 'Table'[Version]="A"))
var _b=CALCULATE(SUM('Table'[Month]),FILTER(ALL('Table'),'Table'[KPI Name]=MAX('Table'[KPI Name]) && 'Table'[Version]="B"))
return IF(_a>= _b,"#1AAB40", "#D64554")

(3)Set the conditional format.

vtangjiemsft_1-1699252487966.pngvtangjiemsft_2-1699252510412.png

(4)Then the result is as follows.

vtangjiemsft_3-1699252672894.png

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

 

Best Regards,

Neeko 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

3 REPLIES 3
v-tangjie-msft
Community Support
Community Support

Hi @ferk_23 ,

 

According to your description, KPI Name and Version as rows and Month as columns are used, and conditional formatting on rows is not supported by design. It is recommended that you create a table visual object.

(1)This is my test data.  

vtangjiemsft_0-1699252312140.png

(2)We can create a measure.

color = 
var _a=CALCULATE(SUM('Table'[Month]),FILTER(ALL('Table'),'Table'[KPI Name]=MAX('Table'[KPI Name]) && 'Table'[Version]="A"))
var _b=CALCULATE(SUM('Table'[Month]),FILTER(ALL('Table'),'Table'[KPI Name]=MAX('Table'[KPI Name]) && 'Table'[Version]="B"))
return IF(_a>= _b,"#1AAB40", "#D64554")

(3)Set the conditional format.

vtangjiemsft_1-1699252487966.pngvtangjiemsft_2-1699252510412.png

(4)Then the result is as follows.

vtangjiemsft_3-1699252672894.png

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

 

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

It worked! I have several months as columns, you also know if it's possible to iterate over the columns and find the column with the previous month? In this case would be October (bc we are in November). The month columns have this format: MMM'YY (Oct'23). 

amitchandak
Super User
Super User

@ferk_23 , Try this out

DifferenceMeasure = IF(
CALCULATE(SUM(Table[Month]), Table[Version] = "A") > CALCULATE(SUM(Table[Month]), Table[Version] = "T"), "#1AAB40", "#D64554")

or

DifferenceMeasure = IF(
CALCULATE(SUM(Table[Month]), ALL(Table), Table[Version] = "A",Table[KPI Name]="Safety") > CALCULATE(SUM(Table[Month]), ALL(Table), Table[Version] = "T",Table[KPI Name]="Safety"), "#1AAB40", "#D64554")

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.