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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
bend1234567
Frequent Visitor

Max value across quarters and years per category

Hi,

I used a daily sales dataset to display a matrix of the summed quarterly sales by Item.

 

Year2017201720172017201720182018201820182018
QtrQ1Q2Q3Q4TotalQ1Q2Q3Q4Total
Itm11020304010080101020120
Itm24030201010020101080120

 

This goes all the way out to Q1 2022, but for the sake of my explanation lets pretent its just 2 years.

 

I'm looking for a way to highlight the specific quarter that had the highest sale, for each item (i.e. for each row of the matrix). So for Itm1, the cell for Q1 2018 would highlight. Similarly for Itm2, the cell for Q4 2018 would highlight.

 

I know the long way to go about it in Power Query, by duplicating tables and making helper columns, and then using Group By and Max. I did implement this, but it really bogged down my refresh and isn't dynamic - i.e. the conditional formatting is unresponsive to me filtering out years. For example, I'd like to be able to filter out 2018 and now Itm1 has Q4 2017 as its max while Itm2 has Q1 2017 as its max.

 

I'm pretty sure what I'm asking about can be accomplished with some sort of combination of measures and conditional formatting based of those measures, but I'm stuck. I'm not great with using the CALCULATE function but I know this will likely be included.

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@bend1234567 , Create a measure like this and use in conditional formatting using field value option

 

Measure =
Var _max = alculate(maxx(values(Table[Qtr]),[Sales]) filter(allselected(Table), Table[Item] = max(Table[Item]))
return
if([sales] =_max, "Green", "White")

 

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/...

View solution in original post

2 REPLIES 2
bend1234567
Frequent Visitor

You're amazing. Thanks so much!

amitchandak
Super User
Super User

@bend1234567 , Create a measure like this and use in conditional formatting using field value option

 

Measure =
Var _max = alculate(maxx(values(Table[Qtr]),[Sales]) filter(allselected(Table), Table[Item] = max(Table[Item]))
return
if([sales] =_max, "Green", "White")

 

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/...

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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