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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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

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

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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