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

 Year 2017 2017 2017 2017 2017 2018 2018 2018 2018 2018 Qtr Q1 Q2 Q3 Q4 Total Q1 Q2 Q3 Q4 Total Itm1 10 20 30 40 100 80 10 10 20 120 Itm2 40 30 20 10 100 20 10 10 80 120

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
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://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
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 !!
2 REPLIES 2
Frequent Visitor

You're amazing. Thanks so much!

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://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
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 !!