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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
acg
Resolver I
Resolver I

List highest score for each provider from a range of tables.

 

 

I have a table with the provider and up to  5 different countries they deal with. THe risk scores have been displayed. I need to be able to say what is the highest risk score for each provider and year.

If there are counties with the same risk score, then the country that appears first is taken. 

IN SQL I solved this sort of thing like this:

, [Highest_Risk] AS(
SELECT *,
(SELECT MAX(v)
FROM (
VALUES (Country_change.[High_risk_country1]),
(Country_change.[High_risk_country2]),
(Country_change.[High_risk_country3]),
(Country_change.[High_risk_country4]),
(Country_change.[High_risk_country5])) AS value(v)

 

What do you do in Power BI?

ProviderCountry 1 risk scoreCountry 2 risk scoreCountry 3 risk scoreCountry 4 risk scoreCountry 5 risk scoreHighest risk score
1003213
2334525
3255323
4000101
5000000
       
       
1 ACCEPTED SOLUTION
FreemanZ
Super User
Super User

hi @acg 

 

1) try to unpivot it in Power Query Editor. Write click the Provider Column and choose unpivot other columns. You make it like this:

FreemanZ_7-1677722494578.png

 

 

2) then plot a table visual with attribute column and a measure as simple as:

 

Measure = MAX(TableName[Value])

 

 

it worked like:

FreemanZ_0-1677722195895.png

 

 

View solution in original post

4 REPLIES 4
CNENFRNL
Community Champion
Community Champion

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUTKAYmMgNgJiQ6VYnWgwyxiKTYDYFCwLkoGpM4ViY7iMCZJpBmCTQDRIxhRNBoJjYwE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Provider = _t, #"Country 1 risk score" = _t, #"Country 2 risk score" = _t, #"Country 3 risk score" = _t, #"Country 4 risk score" = _t, #"Country 5 risk score" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Provider", Int64.Type}, {"Country 1 risk score", Int64.Type}, {"Country 2 risk score", Int64.Type}, {"Country 3 risk score", Int64.Type}, {"Country 4 risk score", Int64.Type}, {"Country 5 risk score", Int64.Type}}),

    Max = Table.AddColumn(#"Changed Type", "Max", each List.Max(List.Skip(Record.ToList(_))))
in
    Max

CNENFRNL_0-1677732116417.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

smpa01
Super User
Super User

@acg  you can do this

highest = 
MAXX (
    {
        MAX ( tbl[Country 1 risk score] ),
        MAX ( tbl[Country 2 risk score] ),
        MAX ( tbl[Country 3 risk score] ),
        MAX ( tbl[Country 4 risk score] ),
        MAX ( tbl[Country 5 risk score] )
    },
    [Value]
)

 

smpa01_0-1677725069686.png

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

hi @smpa01 @acg 

 

that is quite an eye-opener, perfect if there are not too many country columns.

 

follow the logic, it is also good to add a calculated column like:

ColumnHighest = 
MAXX (
    {
        [Country 1 risk score],
        [Country 2 risk score],
        [Country 3 risk score],
        [Country 4 risk score],
        [Country 5 risk score]
    },
    [Value]
)

 

FreemanZ_0-1677728171571.png

 

FreemanZ
Super User
Super User

hi @acg 

 

1) try to unpivot it in Power Query Editor. Write click the Provider Column and choose unpivot other columns. You make it like this:

FreemanZ_7-1677722494578.png

 

 

2) then plot a table visual with attribute column and a measure as simple as:

 

Measure = MAX(TableName[Value])

 

 

it worked like:

FreemanZ_0-1677722195895.png

 

 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.