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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

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
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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