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! Learn more

Reply
ngct1112
Post Patron
Post Patron

DAX - Most Frequent value

Hi,

 

I would like to find the most frequenct value(most repeated times) by DAX. May I know is it possible?

 

Original Table

ItemIDuser
11Peter
12Peter
13Alex
14Peter
15Chris
16Chris
21Alex
22Alex
23Peter

 

Desired Result:

ItemMost Frequency
1Peter
2Alex
1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

To your Table visual, drag the Item field and write these mesures

User count = counta(Data[User])

Most frequency = FIRSTNONBLANK(TOPN(1,VALUES(Data[User]),[User count]),1)

Drag the second measure to your visual.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

22 REPLIES 22
Ashish_Mathur
Super User
Super User

Hi,

To your Table visual, drag the Item field and write these mesures

User count = counta(Data[User])

Most frequency = FIRSTNONBLANK(TOPN(1,VALUES(Data[User]),[User count]),1)

Drag the second measure to your visual.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

Excellent solution! But can it easily be turned into Custom Columns instead of Measures? The reason I ask is that I have implemented your solution for two different fields and would like to be able to collapse and expand for each of them.

Thank you.  I cannot understand why you want to convert a measure into a calculated column formula.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

I have broadcasting data where each program and each episode has a unique ID. There are however more than one program- and episode name behind each ID. Ideally, I would like to have a Matrix visual where I could expand or collapse a selected program or episode - using the most frequent name as a proxy and saving space by not showing the IDs. The problem with Measures is that they can't be added as rows (which is the prerequisite for expanding/collapsing) - they can only be added under Values:

omnis73_1-1718031565120.png

 

I do not understand.  Someone who does will help you.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi,

 

How can I get the number (how many times repeated the most frequent value).

I'd like to display it in a card.

 

Thanks

Hi,

Write the formula suggested in my message.  If t does not work, then share some data to work with, explain the question and show the expected result.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi, apprecaite your feedback. 

It works and give me the value "Name of most frequent client", but I need how many time this client name repeated, for example 10 times. I need it as measure not column nor table.

 

Thanks

Hi,

Drag client to the visual and write this measure

Count = countrows(Data)

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi @Ashish_Mathur , may I have a futher question regarding this formula?
Is it possible I could add a filter in your formula like filter "group" = "B"

Appreciated if you could help

Original:

ItemIDusergroup
11PeterA
12PeterA
13AlexA
14PeterB
15ChrisB
16ChrisB
21AlexA
22AlexA
23PeterB

 

 

Desired result:

ItemMast Frequent(B)
1Chris
2Peter

Hi,

This measure works

Most frequent = CALCULATE(FIRSTNONBLANK(TOPN(1,VALUES(Data[User]),[User count],DESC),1),Data[group]="B")

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

@Ashish_Mathur I am really sorry forget not to mention that "group" itself is a measure.

Its shows the error below when I use the CALAULATE:

A function 'CALCULATE' has been used in a True/False expression that is used as a table filter expression. This is not allowed.

 Is there any way to deal with this case. Appreciated!

Share the link from where i can download your PBI file with your measures already written there.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

@Ashish_Mathur Please see the Sample BI 

I am hoping I could get the sub-total "supplier" as the most frequently shown supplier in the group"A" rather than a MAX value.

Appreciated!

ngct1112_0-1627564697804.png

 

I am confused.  In the Group column, you do not have any entry as A at all.  Do not be in a hurry to post.  Read your own question multiple times before posting.  What exact result do you expect to see in the sub total row and why?


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

I am hoping I could show the users, for each QTY,

1.)which supplier with the lowest cost & the cost (has been achieved)

ngct1112_0-1627610859889.png

2.) Before Expanding the QTY, could it show the most frequenct supplier from all the QTY.

Like your provided measure, except the filter component is a Measure rather a column now. 

**Filter "Rank by Supplier" = 1

 

Supplier 1 = CALCULATE(FIRSTNONBLANK(TOPN(1,VALUES(Table[Group]),[User count],DESC),1),[Rank by Supplier]=1)

 

ngct1112_1-1627611182604.png

For this case, the supplier 1's result should be "A" since "A" is the most frequent supplier in all QTY

The reason of doing this is letting the user know generally, which supplier should be used since that supplier with the lowest cost for most cases.

 

May I know is it achievable? 

 

 

I still do not understand your expected result.  Someone else who does will help you.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

@Ashish_Mathur No worries. You did help a lot. Great thanks for that.

@Ashish_Mathur Thanks Ashish, it works fine in my model. Appreciated.

You are welcome.  If my previous reply helped, please mark that as Answer.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

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