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
rhaining
Microsoft Employee
Microsoft Employee

looking to get most common value for a field during summarize

I have data similar to this:

 

Sale Id | Item Id | Color

===============

1 | Toy Car | Blue

2 | Stuffed Animal | Green

3 | Toy Car | Red

4 | Toy Car | Blue

5 | Stuffed Animal | Purple

 

I want to summarize the most common color for each item.  In effect I'm looking for the "mode" of a set of string values.  So the output would be:

 

Item Id | Most Common Color | MCC Count

============================

Toy Car | Blue | 2

Stuffed Animal | Purple | 1

 

(Note that there is a tie for Green or Purple for Stuffed Animal.  I'm not picky.  I want one of the colors that is tied for top.)

 

Perf. is a bit of a concern so I'm hoping to find a way to do this in a single summarize operation.

 

I can live without the most common color count column, if that's harder to generate.

 

Thanks in advance!

 

1 REPLY 1
Greg_Deckler
Community Champion
Community Champion

@rhaining Try:

MCC Count Measure =
  VAR __Table = SUMMARIZE('Table', [Color]), "__Count", COUNTROWS('Table'))
  VAR __Result = MAXX(__Table, [__Count])
RETURN
  __Result

Most Common Color Measure =
  VAR __Table = SUMMARIZE('Table', [Color]), "__Count", COUNTROWS('Table'))
  VAR __Max = MAXX(__Table, [__Count])
  VAR __Result = MAXX(FILTER(__Table, [__Count] = __Max), [Color])
RETURN
  __Result


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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

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.

Top Solution Authors
Top Kudoed Authors