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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Manas
New Member

How to give conditional Formatting to Matrix with data bars or background colors for time trend?

How to give conditional Formatting to Matrix with data bars or background colours for time trends?

For eg., the following image shows Bike sales for 4 years. Need to have colour data bars /background colours to see the trend whether increasing or decreasing based on each year's sales amount.

 

 

MATRIX-CONDITIONAL FORMATTING--QUERY.png

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Manas ,

Aditya_Meshram_1-1660048110463.png

Is this how you want it?
You can use the measure given for the conditional formatting of cell color. 

 

Cell Color = 
var a = SUM('Table'[Value])
var b = CALCULATE(SUM('Table'[Value]),SAMEPERIODLASTYEAR('Calendar'[Date]))
return
   IF(
       a>b,"#b3ffd9",IF(ISBLANK(a) || ISBLANK(b),"#ffffff","#ffb3b3")
   )

 

Go to conditional formatting of value, select background colour, then select Field Value and select this measure.

Attached .pbix for reference.
Manas.pbix

Regards,
Aditya

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @Manas ,

Aditya_Meshram_1-1660048110463.png

Is this how you want it?
You can use the measure given for the conditional formatting of cell color. 

 

Cell Color = 
var a = SUM('Table'[Value])
var b = CALCULATE(SUM('Table'[Value]),SAMEPERIODLASTYEAR('Calendar'[Date]))
return
   IF(
       a>b,"#b3ffd9",IF(ISBLANK(a) || ISBLANK(b),"#ffffff","#ffb3b3")
   )

 

Go to conditional formatting of value, select background colour, then select Field Value and select this measure.

Attached .pbix for reference.
Manas.pbix

Regards,
Aditya

amitchandak
Super User
Super User

@Manas , Create a YOY measures, Prefer to use a separate date/year table

 

//Only year vs Year, not a level below

This Year = CALCULATE(sum('Table'[Qty]),filter(ALL('Date'),'Date'[Year]=max('Date'[Year])))
Last Year = CALCULATE(sum('Table'[Qty]),filter(ALL('Date'),'Date'[Year]=max('Date'[Year])-1))
diff = [This Year]-[Last Year ]
diff % = divide([This Year]-[Last Year ],[Last Year ])

 

use this diff in conditional formatting , rule

or create a color measure and use in conditional formatting using field value

 

color = if([diff]>0, "Green", "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/...

 

https://amitchandak.medium.com/power-bi-where-is-the-conditional-formatting-option-in-new-format-pan...

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

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.