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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
oneillp111
Frequent Visitor

Trying to calculate winners of superlatives

I have a small dataset with a column of questions, "Who is most likely to succeed?", "Who is Most likely to be a spy", etc.  Then a column with employee responses.  I am trying to do a calculated measure so I can see which name got the most votes for each question.  I am able to get the number of answers for each question but I want to have a column that shows who got the most votes.

 

oneillp111_0-1664889247223.png

QuestionAnswer
Who is most likely to Accidently put their shirt on backwards?Steve
Who is most likely to Accidently put their shirt on backwards?Dave
Who is most likely to Accidently put their shirt on backwards?Mike
Who is most likely to Accidently put their shirt on backwards?Mike
Who is most likely to Accidently put their shirt on backwards?Mike
Who is most likely to Accidently walk into a wall?Joe
Who is most likely to Accidently walk into a wall?Larry
Who is most likely to Accidently walk into a wall?Larry
Who is most likely to Accidently walk into a wall?Bill

 

So Question 1 next column would be Mike

2 would be Larry

 

Can anyone point me in the right direction?

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@oneillp111 Try:

Measure =
  VAR __Table = SUMMARIZE('Table',[Answer],"__Count",COUNTROWS('Table')
  VAR __Max = MAXX(__Table,[__Count])
RETURN
  MAXX(FILTER(__Table,[__Count] = __Max),[Answer])


or

Measure =
  VAR __Table = SUMMARIZE('Table',[Answer],"__Count",COUNTROWS('Table')
  VAR __Max = MAXX(__Table,[__Count])
RETURN
  CONCATENATEX(FILTER(__Table,[__Count] = __Max),[Answer],", ")


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

3 REPLIES 3
Greg_Deckler
Super User
Super User

@oneillp111 Try:

Measure =
  VAR __Table = SUMMARIZE('Table',[Answer],"__Count",COUNTROWS('Table')
  VAR __Max = MAXX(__Table,[__Count])
RETURN
  MAXX(FILTER(__Table,[__Count] = __Max),[Answer])


or

Measure =
  VAR __Table = SUMMARIZE('Table',[Answer],"__Count",COUNTROWS('Table')
  VAR __Max = MAXX(__Table,[__Count])
RETURN
  CONCATENATEX(FILTER(__Table,[__Count] = __Max),[Answer],", ")


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

thanks @Greg_Deckler , can you clarify somethings for me, what is "___Count" in line 2

@oneillp111 Just a variable name. I always prefix my variable names with a double underscore for whatever reason (mainly to prevent misidentification with columns and measures and such)



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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