cancel
Showing results for 
Search instead for 
Did you mean: 
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/...



New Power BI Features
Datamarts: https://youtu.be/8tskWsJTEpg
Field Parameters : https://youtu.be/lqF3Wa1FllE?t=70
Did I answer your question? Mark my post as a solution! Appreciate your Kudos!! !!
Dashboard of My Blogs !! Connect on Linkedin !! Proud to be a Super User!
Want To Learn Power BI
Learn Power BI Beginners !! Advance Power BI Concepts !! Power BI For Tableau User !! Learn Power BI in Hindi !!
!! Subscribe to my youtube Channel !!

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



New Power BI Features
Datamarts: https://youtu.be/8tskWsJTEpg
Field Parameters : https://youtu.be/lqF3Wa1FllE?t=70
Did I answer your question? Mark my post as a solution! Appreciate your Kudos!! !!
Dashboard of My Blogs !! Connect on Linkedin !! Proud to be a Super User!
Want To Learn Power BI
Learn Power BI Beginners !! Advance Power BI Concepts !! Power BI For Tableau User !! Learn Power BI in Hindi !!
!! Subscribe to my youtube Channel !!

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power BI Dev Camp Session 23 768x460.jpg

Check it Out!

Mark your calendars and join us on Thursday, June 30 at 11a PDT for a great session with Ted Pattison!

Top Solution Authors
Top Kudoed Authors