cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Nossair
Frequent Visitor

How to get the value of Column A for the row that has the highest value in column B ?

I have a database of Premier League matches for 20 seasons, along with the matchday and the point total for each team in every match, so I wanna create a "Season" table out of it, and add a "Champion" calculated column that gives you the value of "HomeTeam" or "AwayTeam" that has the highest value out of both "HTPointsSeason" and "ATPointsSeason" in MatchWeek 38 rows (basically the team that has the most points after the last match of the season, which is made a little more complicated by the fact that teams are spread over HomeTeam and AwayTeam, so if the highest value is in the ATPS column, I gotta get the value of that row in AwayTeam, and respectively for HTPS and HomeTeam).

 

Is there any way to both get the value of the row in another column AND get the row and the column that have the highest value?

 

Here's the data:

 

points.pngteams.png

 

(Also, if there's a way to do this, how to handle tie breakers in Power BI ? As in if there's a draw on points at the end of the season like in 2011/12, how to make it so it chooses the team with the highest goal difference among the teams tied for most points ?)

 

Sorry if this seems obvious, but I'm still learning and I like being confronted with these learning opportunities.

1 ACCEPTED SOLUTION

Accepted Solutions
Super User IV
Super User IV

Re: How to get the value of Column A for the row that has the highest value in column B ?

OK, I think I am starting to follow. You want a multi-column aggregation. Luckily, I invented one quite a while ago. 

 

https://community.powerbi.com/t5/Quick-Measures-Gallery/Multi-Column-Aggregations-MC-Aggregations/m-...

 


---------------------------------------

Not the Power BI thought police...

I have NEW book! 
DAX Cookbook from Packt
Over 120 DAX Recipes!
Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!

View solution in original post

4 REPLIES 4
Super User IV
Super User IV

Re: How to get the value of Column A for the row that has the highest value in column B ?

Not very clear, but earlier can help

Max value = maxx(filter(table,table[team] =earlier(table[team]) && table[A] =earlier(table[A])),table[B])

 

when you have use date

Last Date Time = maxx(filter(table,table[Date Time]<earlier(table[Date Time])),table[Date Time])

 

You can add/remove conditions at per need





Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
In case it does not help, please provide additional information and mark me with @
My Recent Blogs -Decoding Direct Query - Time Intelligence, Winner Coloring on MAP,
HR Analytics, Power BI Working with Non-Standard TimeAnd Comparing Data Across Date Ranges
Proud to be a Super User! Linkedin


Super User IV
Super User IV

Re: How to get the value of Column A for the row that has the highest value in column B ?

Could you post your data as text and provide expected result? Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490


---------------------------------------

Not the Power BI thought police...

I have NEW book! 
DAX Cookbook from Packt
Over 120 DAX Recipes!
Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!

Nossair
Frequent Visitor

Re: How to get the value of Column A for the row that has the highest value in column B ?

@Greg_Deckler 

HomeTeamAwayTeam
Manchester UnitedLeicester City
West Ham UtdLiverpool FC
Aston VillaArsenal

 

HomeTeamPointsAwayTeamPoints
8159
4694
3765

 

In this simplified example, the script would look at the HTP and ATP columns, see that the max in both of them is 94, so it'd return the value associated with it, which is Liverpool (1st scan for the highest value in both (94), then get the column it's in to know if we should look in HomeTeam or AwayTeam (it's in ATP so AT), and the row to know which value to return (2nd row, so Liverpool)).

Super User IV
Super User IV

Re: How to get the value of Column A for the row that has the highest value in column B ?

OK, I think I am starting to follow. You want a multi-column aggregation. Luckily, I invented one quite a while ago. 

 

https://community.powerbi.com/t5/Quick-Measures-Gallery/Multi-Column-Aggregations-MC-Aggregations/m-...

 


---------------------------------------

Not the Power BI thought police...

I have NEW book! 
DAX Cookbook from Packt
Over 120 DAX Recipes!
Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!

View solution in original post

Helpful resources

Announcements
New Ranks Launched March 24th!

New Ranks Launched March 24th!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power BI Community!

‘Better Together’ Contest Finalists Announced!

‘Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

Arun 'Triple A' Event Video, Q&A, and Slides

Arun 'Triple A' Event Video, Q&A, and Slides

Missed the Arun 'Triple A' event or want to revisit it? We've got you covered! Check out the video, Q&A, and slides now.

Top Solution Authors
Top Kudoed Authors