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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
andre_kroker
Frequent Visitor

DAX Measure to return the name of the largest category

Hi All()

Considering I have the following column chart:

andre_kroker_2-1645710149236.png

Where the category in the axis is Age Range, and the values on each column are actually a measure the counts the number of a certain group of people falling in those categories (it is actually a very simple measure).

I want a card that returns the category with the largest amount of people on it. Considering the chart above, the card would return "De 20 a 30". As simple as that.

Any thoughts?

1 ACCEPTED SOLUTION
ValtteriN
Super User
Super User

Hi,

Try utilizing MAXX:
e.g.


Measure 18 = var _table = topn(1,SUMMARIZE('Table (7)','Table (7)'[Column1],"Sum",SUM('Table (7)'[Column2])),SUM('Table (7)'[Column2]))
return
maxX(_table,'Table (7)'[Column1])


You can replace sum with count. 


Example data:
ValtteriN_0-1645713972556.png



End result:

ValtteriN_1-1645713986598.png



I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!

My LinkedIn: https://www.linkedin.com/in/n%C3%A4ttiahov-00001/





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

Proud to be a Super User!




View solution in original post

2 REPLIES 2
ValtteriN
Super User
Super User

Hi,

Try utilizing MAXX:
e.g.


Measure 18 = var _table = topn(1,SUMMARIZE('Table (7)','Table (7)'[Column1],"Sum",SUM('Table (7)'[Column2])),SUM('Table (7)'[Column2]))
return
maxX(_table,'Table (7)'[Column1])


You can replace sum with count. 


Example data:
ValtteriN_0-1645713972556.png



End result:

ValtteriN_1-1645713986598.png



I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!

My LinkedIn: https://www.linkedin.com/in/n%C3%A4ttiahov-00001/





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

Proud to be a Super User!




Dear @ValtteriN 

The solution you provided works well, Thank you SO MUCH for your prompt response 😃
I chose to author the measure a bit different, with an ADDCOLUMNS statement surrounding the measure. (Marco Russo and Alberto Ferrari say this is a best practice in some cases. Please refer to this video https://www.sqlbi.com/articles/best-practices-using-summarize-and-addcolumns/).

Thank you so much once again! Going accept this as a solution and connect with you on Linkedin.
Regards!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.

Top Solution Authors