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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
kkassel
Frequent Visitor

visual showing max value for each year with corresponding name

I have a set of data where I'm trying to create a table or matrix that shows the max value of a given year and the corresponding name of the person.  This data is NBA stats. I want to be able to show the player in each season with the highest points per game. With the table sorted in season order. Below I have a small sample set and then what I want the visual to display.

Sample Data:

YearPlayerGames PlayedPointsPts per G
2016James Harden82237629.0
2017Russell Westbrook81255831.6
2017James Harden81235629.1
2015James Harden81221727.4
2016Stephen Curry79237530.1
2017Isaiah Thomas76219928.9
2017Anthony Davis75209928.0
2016Kevin Durant72202928.2
2015LeBron James69174325.3
2015Anthony Davis68165624.4
2015Russell Westbrook67188628.1
2015Kevin Durant2768625.4

 

Visual Result:

YearPlayerPts per G
2015Russell Westbrook28.1
2016Stephen Curry30.1
2017Russell Westbrook31.6

 

4 ACCEPTED SOLUTIONS
Ashish_Mathur
Super User
Super User

Hi,

Try these measures

PPG = MAX(Data[Pts per G])
Pl = CONCATENATEX(TOPN(1,VALUES(Data[Player]),[PPG]),Data[Player],", ")

Hope this helps.

Ashish_Mathur_0-1708220736894.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

Ashish_Mathur
Super User
Super User

Hi,

This M code works as well

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("dZHLasMwEEV/RXgdjDWyHl62zaKvVVvoImShEoFNE6lIdiB/X80oIY4hG4lBZ+7cudpsKmi4qlbVqz24xJ5t3DmfSwP5AKHxCbpquyJQ5+pjSsnt9+zbpfEnhvCLNEdMSpMvwWs155fChApZhGt+QeU9FEgFdN1eUGz9HN1f7zx7mmI85Vp3xS/KiOYqi70vyQ62Z199ONiELM3mHbWY+ma7Bz/2wZ/Y2h4HYlEQmjM7d/DmjoNn6ylaPyJIgTVwFoX5Xu/uMQbPaL1cKmS4bgWFVos5upyvMFKuSlztNQN55ycULsGNUcXGTbwLx6BJXxUXWXn7Dw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Year = _t, Player = _t, #"Games Played" = _t, Points = _t, #"Pts per G" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Year", Int64.Type}, {"Player", type text}, {"Games Played", Int64.Type}, {"Points", Int64.Type}, {"Pts per G", type number}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Year"}, {{"Pl", each Table.Max(_,"Player")}, {"Max", each List.Max([Pts per G]), type nullable number}}),
    #"Expanded Pl" = Table.ExpandRecordColumn(#"Grouped Rows", "Pl", {"Player"}, {"Player"}),
    #"Sorted Rows" = Table.Sort(#"Expanded Pl",{{"Year", Order.Ascending}})
in
    #"Sorted Rows"

Hope this helps.

Ashish_Mathur_1-1708221024853.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

ThxAlot
Super User
Super User

ThxAlot_0-1708240485161.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LeanAndPractise(Everyday)


)



View solution in original post

v-xuxinyi-msft
Community Support
Community Support

Hi @kkassel 

 

@ThxAlot @Ashish_Mathur  GOOD ANSWER!

 

I have another method.

 

You can create a measure.

 

Measure = 
VAR _max = CALCULATE(MAX([Pts per G]), ALLEXCEPT('Table', 'Table'[Year]))
RETURN
IF( MAX([Pts per G]) = _max, 1, 0) 

 

 

Put the measure into the visual-level filters, set up show items when the value is 1.

vxuxinyimsft_0-1708393253673.png

 

Best Regards,
Yulia Xu

 

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

View solution in original post

4 REPLIES 4
v-xuxinyi-msft
Community Support
Community Support

Hi @kkassel 

 

@ThxAlot @Ashish_Mathur  GOOD ANSWER!

 

I have another method.

 

You can create a measure.

 

Measure = 
VAR _max = CALCULATE(MAX([Pts per G]), ALLEXCEPT('Table', 'Table'[Year]))
RETURN
IF( MAX([Pts per G]) = _max, 1, 0) 

 

 

Put the measure into the visual-level filters, set up show items when the value is 1.

vxuxinyimsft_0-1708393253673.png

 

Best Regards,
Yulia Xu

 

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

ThxAlot
Super User
Super User

ThxAlot_0-1708240485161.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LeanAndPractise(Everyday)


)



Ashish_Mathur
Super User
Super User

Hi,

This M code works as well

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("dZHLasMwEEV/RXgdjDWyHl62zaKvVVvoImShEoFNE6lIdiB/X80oIY4hG4lBZ+7cudpsKmi4qlbVqz24xJ5t3DmfSwP5AKHxCbpquyJQ5+pjSsnt9+zbpfEnhvCLNEdMSpMvwWs155fChApZhGt+QeU9FEgFdN1eUGz9HN1f7zx7mmI85Vp3xS/KiOYqi70vyQ62Z199ONiELM3mHbWY+ma7Bz/2wZ/Y2h4HYlEQmjM7d/DmjoNn6ylaPyJIgTVwFoX5Xu/uMQbPaL1cKmS4bgWFVos5upyvMFKuSlztNQN55ycULsGNUcXGTbwLx6BJXxUXWXn7Dw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Year = _t, Player = _t, #"Games Played" = _t, Points = _t, #"Pts per G" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Year", Int64.Type}, {"Player", type text}, {"Games Played", Int64.Type}, {"Points", Int64.Type}, {"Pts per G", type number}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Year"}, {{"Pl", each Table.Max(_,"Player")}, {"Max", each List.Max([Pts per G]), type nullable number}}),
    #"Expanded Pl" = Table.ExpandRecordColumn(#"Grouped Rows", "Pl", {"Player"}, {"Player"}),
    #"Sorted Rows" = Table.Sort(#"Expanded Pl",{{"Year", Order.Ascending}})
in
    #"Sorted Rows"

Hope this helps.

Ashish_Mathur_1-1708221024853.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Ashish_Mathur
Super User
Super User

Hi,

Try these measures

PPG = MAX(Data[Pts per G])
Pl = CONCATENATEX(TOPN(1,VALUES(Data[Player]),[PPG]),Data[Player],", ")

Hope this helps.

Ashish_Mathur_0-1708220736894.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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