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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
askpbiuser
Helper I
Helper I

Sort by column values with multiple fields in rows in matrix

Hi, I need to display Country and Customer coming from different Dim tables and show them in rows in matrix visual. The field ( Product) in Columns in Matrix is from a different Dim table all connected to Fact table by one-to-many relationship.

The below measure works fine when I have either Country or Customer in rows, but as soon as I add both fields, the measure doesn't like it.
I need to basically highlight the minimum value for each Product column by using the below measure in Conditional formatting.
The measure I tried -

Background Measure =

VAR _1 = CALCULATETABLE(
ADDCOLUMNS
(SUMMARIZE('Fact','Dim Country'[Country], 'Dim Product'[Product]),
"@Amt", [Value]
),
ALLSELECTED(''Dim Product'[Product])
)
var MinValue = MINX(_1, [@Amt])
var MaxValue = MAXX(_1, [@Amt])
var CurrentValue = [Value]
var Result =
SWITCH(TRUE(),
CurrentValue = MinValue, 1,
CurrentValue = MaxValue, 2, BLANK())
RETURN Result

If I add Country to rows in matrix  and customer coming from Dim Customer[Customer] to the above measure in summarize, it does not give right result. It only works when I have one field say Country in rows and product in columns.Could someone guide on what I am doing wrong? I need the below output when both Country and Customer are in rows.

askpbiuser_1-1693563010361.png

 

 

1 REPLY 1
some_bih
Super User
Super User

Hi @askpbiuser  your part for SUMMARIZE define "later" output

SUMMARIZE('Fact','Dim Country'[Country], 'Dim Product'[Product]) 

combined with ALLSELECTED(''Dim Product'[Product]) which "missing" Dim Customer table / some column

Try to add to this part what you need, like customer.

Hope this help. Kudos appreciated.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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