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
Gopinath_iyer
Helper II
Helper II

Color formatting

Hi All,

 

I need help in color formatting in matrix view. I need different background colors for 

1) Category is "Actual" and month is less than current month (Jan to May i.e all cells with value 200 in sample output)

2) Category is "Actual" and month is greater than current month (June to Dec i.e all cells with value 100 in sample output)

3) Category is "Budget" all months (Jan to Dec i.e all cells with value 110 in sample output)

 

Sample output - 

Row LabelsJan'22Feb'22Mar'22Apr'22May'22Jun'22Jul'22Aug'22Sep'22Oct'22Nov'22Dec'22
Actual200200200200200100100100100100100100
Budget110110110110110110110110110110110110
Grand Total310310310310310210210210210210210210

 

Sample data - 

CategoryMonthAmount
ActualJan'22200
ActualFeb'22200
ActualMar'22200
ActualApr'22200
ActualMay'22200
ActualJun'22100
ActualJul'22100
ActualAug'22100
ActualSep'22100
ActualOct'22100
ActualNov'22100
ActualDec'22100
BudgetJan'22110
BudgetFeb'22110
BudgetMar'22110
BudgetApr'22110
BudgetMay'22110
BudgetJun'22110
BudgetJul'22110
BudgetAug'22110
BudgetSep'22110
BudgetOct'22110
BudgetNov'22110
BudgetDec'22110
1 ACCEPTED SOLUTION
PaulDBrown
Community Champion
Community Champion

Here is one way:
First, the model:

Model.png

 

And the Measure for conditional formatting:

1) Backround Colour:

Colour code = 
VAR _today = YEAR(TODAY()) * 100 + MONTH(TODAY())
RETURN
SWITCH(SELECTEDVALUE('Dim Category'[Category]),
"Actual", 
IF(MAX('Dim Period'[YearMonth]) < _today, "Green", "Red"),
"Budget",
"Blue")

2: Text Colour:

TEXT COLOUR = 
IF(ISINSCOPE('Dim Period'[Month]), "White")

Result.png

I've attached the sample PBIX file





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






View solution in original post

2 REPLIES 2
PaulDBrown
Community Champion
Community Champion

Here is one way:
First, the model:

Model.png

 

And the Measure for conditional formatting:

1) Backround Colour:

Colour code = 
VAR _today = YEAR(TODAY()) * 100 + MONTH(TODAY())
RETURN
SWITCH(SELECTEDVALUE('Dim Category'[Category]),
"Actual", 
IF(MAX('Dim Period'[YearMonth]) < _today, "Green", "Red"),
"Budget",
"Blue")

2: Text Colour:

TEXT COLOUR = 
IF(ISINSCOPE('Dim Period'[Month]), "White")

Result.png

I've attached the sample PBIX file





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






amitchandak
Super User
Super User

@Gopinath_iyer , You need to create a color measure like this and use it in conditional formatting using the field value option

 

color =
var _change =Calculate(Sum(Table[Amount]), Table[Category]= "Actual") - Calculate(Sum(Table[Amount]), Table[Category]= "Budget")
return
SWITCH (
TRUE(),
_change > 0, "green",
_change = 0, "blue",
_change < 0, "red"
)

 

How to do conditional formatting by measure and apply it on pie?
https://www.youtube.com/watch?v=RqBb5eBf_I4&list=PLPaNVDMhUXGYo50Ajmr4SgSV9HIQLxc8L
https://community.powerbi.com/t5/Community-Blog/Power-BI-Conditional-formatting-the-Pie-Visual/ba-p/...

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.