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
magnusks
Helper I
Helper I

Count most common text in column and display value

I have a table that looks something like this: 

 

Table name: Purchases

Member IDPurchased

Member IDPurchased
1Car
2Car
3House
4Car
5House
6Car
7Car

 

In this case there are 5 cars and 2 houses.

 

I want to make a write a measure in DAX so I can display on a card the most frequently purchased item and the number of times that item have been purchased. In this case: 5 cars.

 

Thanks

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @magnusks ,

Create a measure, get the maximum number and its name.

Measure = 
var _table=
SUMMARIZE('Table',[Purchased],"Count",COUNTX(FILTER(ALL('Table'),'Table'[Purchased]=MAX('Table'[Purchased])),[Purchased]))
var _table2=
FILTER(
    _table,[Count]=MAXX(_table,[Count]))
return
MAXX(_table2,[Purchased])&" "&MAXX(_table2,[Count])

The final result obtained is shown below.

vkaiyuemsft_0-1707293305191.png

If your Current Period does not refer to this, please clarify in a follow-up reply.

 

Best Regards,

Clara Gong

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

6 REPLIES 6
Anonymous
Not applicable

Hi @magnusks ,

Create a measure, get the maximum number and its name.

Measure = 
var _table=
SUMMARIZE('Table',[Purchased],"Count",COUNTX(FILTER(ALL('Table'),'Table'[Purchased]=MAX('Table'[Purchased])),[Purchased]))
var _table2=
FILTER(
    _table,[Count]=MAXX(_table,[Count]))
return
MAXX(_table2,[Purchased])&" "&MAXX(_table2,[Count])

The final result obtained is shown below.

vkaiyuemsft_0-1707293305191.png

If your Current Period does not refer to this, please clarify in a follow-up reply.

 

Best Regards,

Clara Gong

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

Thank you Clara. This worked 🙂

Daniel29195
Super User
Super User

@magnusks 

output : 

Daniel29195_0-1707258304171.png

 

measure

 

Measure 8 = 
var ds = 
TOPN(1,
ADDCOLUMNS(
    VALUES('count'[Purchased]),
    "x", CALCULATE(COUNTROWS('count')
    )
),
[x],
DESC
)

var n =  SELECTCOLUMNS(ds,'count'[Purchased])
var nn =  SELECTCOLUMNS(ds,[x])

return

n & ":" & nn

 

 

 

If my answer helped sort things out for you, i would appreciate a thumbs up 👍 and mark it as the solution
It makes a difference and might help someone else too. Thanks for spreading the good vibes! 🤠

 

Thanks Daniel. I tried it but there seems to be something wrong in: 

var n =  SELECTCOLUMNS(ds,'count'[Purchased])

 

It doesnt "allow" me to insert the Purchased column from the Count-table. Any suggestions? 🙂

 

Cheers

@magnusks 

the table name is count  from my side. 

yours i assume is different. 

you need to change the 'count' with the table_name which you have on your side. 

 

@magnusks 

to have 5 cars  : 

change the last line to : nn & " " & n

 

 

If my answer helped sort things out for you, i would appreciate a thumbs up 👍 and mark it as the solution
It makes a difference and might help someone else too. Thanks for spreading the good vibes! 🤠

 

 

Helpful resources

Announcements
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

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