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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
dwelsh
Advocate I
Advocate I

Matrix with Max Value in Row Highlighting and Descending Date Columns

I want to create a Matrix visual with the max value in each row highlighted and descending date column. I can get each to function independently but not together. When I try to combine, every row is highlighted (see below)

 

dwelsh_0-1739540851697.png

 

The bottom matrix has rows Stores, columns Date Desc and value Sales.

Date Desc is a column equal to the Date column and is sorted by Date Ranked column:

Date Rank = rankx('Data', [Date])

 

Here is the Measure for my Highlighting:

MaxInRowDateDesc = 
VAR __MaxUnits = 
MAXX(
    ALLSELECTED( 'Data'[Date Desc] ),
    [Sales]
)
RETURN
IF( 
    [Sales] = __MaxUnits,
    "Yellow"
)

 

Here are the Cell Element Background color settings for the Sales column:

dwelsh_1-1739541520400.png

 

The settings are causing every value to be highlighted yellow. What is odd, is if I am sorting Date Desc by itself, the highest value in each row works correctly. It only turns every value yellow when Date Desc is sorted by Date Rank.

 

2025-02-14_08-13-19.gif

 

Is there something I am doing incorrectly or is this a PBI limitiation? Is there a different way to acheive this?

1 ACCEPTED SOLUTION
Ritaf1983
Super User
Super User

Hi @dwelsh 
Yes this is a known issue, sort column is a part of the dax query, sow when the formula ignoring the date column, it should ignore the sort column too.
Modify the formula of ranking to :

MaxInRowDateDesc = 
VAR __MaxUnits = 
MAXX(
    ALLSELECTED( 'Data'[Date Desc], 'Data'[Date rank] ),
    [Sales]
)
RETURN
IF( 
    [Sales] = __MaxUnits,
    "Yellow"
)

It should work.

For more details please refer to the linked video of Alberto Ferrari :

https://www.youtube.com/watch?v=XmGfXqWxOak

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi, @dwelsh 

 

I tried adding the index column in Power Query.

vzhangtinmsft_0-1739780159661.png

Table.Group(#"Sorted Rows", {"Store"}, {{"Index", each Table.AddIndexColumn(_,"Index",1,1), type table}})

vzhangtinmsft_1-1739780239994.pngvzhangtinmsft_2-1739780281549.png

Expand the results of the table:

vzhangtinmsft_3-1739780324231.png

Date Column sort by Index column.

Measure Color = Var _Max= MAXX(ALLEXCEPT(Data,Data[Store]),[Sales])
RETURN
IF([Sales]=_Max,"Yellow")

vzhangtinmsft_4-1739780435878.png

Is this the result you expected?

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Ritaf1983
Super User
Super User

Hi @dwelsh 
Yes this is a known issue, sort column is a part of the dax query, sow when the formula ignoring the date column, it should ignore the sort column too.
Modify the formula of ranking to :

MaxInRowDateDesc = 
VAR __MaxUnits = 
MAXX(
    ALLSELECTED( 'Data'[Date Desc], 'Data'[Date rank] ),
    [Sales]
)
RETURN
IF( 
    [Sales] = __MaxUnits,
    "Yellow"
)

It should work.

For more details please refer to the linked video of Alberto Ferrari :

https://www.youtube.com/watch?v=XmGfXqWxOak

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

Thank you! That did it and seems so obvious now.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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