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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Crobby
Regular Visitor

Custom conditional formatting comparing values

Capture.PNG

 

I am hoping you may be able to assist in working out this conditional formatting.

The picture you see is the data taken from AAS (Azure Analytics Services). All the measure are created using DAX and this the final output in a matrix visual.

I wanted to use a conditional formatting where it takes the latest two dates of customer and compare the latest % space. If the % is lesser than the previous date then it should be highlighted in RED (as you see in the Picture - for customer B). The latest date for Customer B is 03-02-2022 (50) it is compared with 01-02-2022 (80) so the date 03-02 space has gone less. Same for Customer C.

I tried with some DAX calculation but it was not working.

3 REPLIES 3
amitchandak
Super User
Super User

@Crobby , Try a measure like this and use that in conditional formatting using field value option

 


measure =
var _max2 = maxx(filter(allselected(Table), Table[Customer] = max(Table[Customer]) && Table[Date] < Max([Date])), Table[Date])
var _slast = calculate([%space],filter( allselected(Table), Table[Date] = _max2))
return
if([%space] <_slast, "red", "white")

 

or

 


measure =
var _max = maxx(filter(allselected(Table), Table[Customer] = max(Table[Customer])), Table[Date])
var _max2 = maxx(filter(allselected(Table), Table[Customer] = max(Table[Customer]) && Table[Date] < Max([Date])), Table[Date])
var _slast = calculate([%space],filter( allselected(Table), Table[Date] = _max2))
return
if([%space] <_slast, "red", "white")

 

How to do conditional formatting by measure and apply it on pie?: https://youtu.be/RqBb5eBf_I4

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

Hi @amitchandak Can you explain this line and why it is used 

var _slast = calculate(Table[Shelfspace],filter( allselected(Table), Table[Date] = _max2))
i am facing few issues in particular cases.

@Crobby , is this a measure Shelf_Analytics[Shelfspace] ?

 

if not use some aggregation

 

var _slast = calculate(sum(Shelf_Analytics[Shelfspace]),filter( allselected(Shelf_Analytics), Shelf_Analytics[SMFeedback_Date] = _max2))

 

in case you are looking for column replace max with earlier and you can remove allselected from tbale

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
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors