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

Join the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now

Reply
Anonymous
Not applicable

Specifying MODE (or a user-defined aggregate function) when using DAX SUMMARIZE

I cannot find a MODE function in DAX. I need to use it in conjunction with SUMMARISE

I don't want to do it in Power M Query (though have done successfully in the past)
And I cannot find a way of writing a custom user-defined function.
 
Is MODE in the plan for Power BI? Or being able to write custom user-defined functions?
 
Mike
2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@Anonymous , refer if old solution can help

https://community.powerbi.com/t5/Desktop/Calculating-modes/m-p/46313

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

Anonymous
Not applicable

Hi  @Anonymous  ,

This is the data I created. I define the rules to calculate the most frequent string of name:

v-yangliu-msft_0-1610934271306.png

I learned that the mode expression is the most frequently displayed value, and you can use this method instead:

1. Create Calculated column.

Column =
VAR summary =
     SUMMARIZE (
        'Table',
        'Table'[name],
        "Count",COUNTX(FILTER('Table','Table'[name]=EARLIER('Table'[name])),'Table'[name])
    )   
    VAR _max =
    MAXX ( summary, [Count])
RETURN
    MAXX ( FILTER ( summary, [Count] = _max ), [name] )

2. Result:

v-yangliu-msft_1-1610934271311.png

You can downloaded PBIX file from here.

 

Best Regards,

Liu Yang

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

5 REPLIES 5
Anonymous
Not applicable

Hi  @Anonymous  ,

This is the data I created. I define the rules to calculate the most frequent string of name:

v-yangliu-msft_0-1610934271306.png

I learned that the mode expression is the most frequently displayed value, and you can use this method instead:

1. Create Calculated column.

Column =
VAR summary =
     SUMMARIZE (
        'Table',
        'Table'[name],
        "Count",COUNTX(FILTER('Table','Table'[name]=EARLIER('Table'[name])),'Table'[name])
    )   
    VAR _max =
    MAXX ( summary, [Count])
RETURN
    MAXX ( FILTER ( summary, [Count] = _max ), [name] )

2. Result:

v-yangliu-msft_1-1610934271311.png

You can downloaded PBIX file from here.

 

Best Regards,

Liu Yang

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

 

Anonymous
Not applicable

Thank you. I can see this works.

I still think Power BI would be better if it had the following aggregate functions:

1) MODE (as in this problem)

2) Concatenate all unique strings, sorted. This is often useful to aggregate text strings

amitchandak
Super User
Super User

@Anonymous , refer if old solution can help

https://community.powerbi.com/t5/Desktop/Calculating-modes/m-p/46313

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Thank you. I did get this working.

Though I still think that MODE should be offered as a standard aggregate function

Anonymous
Not applicable

Thank you. I saw that in my research but can't work out how to use the formula. Does it define a MODE function? Or somehow add a column?

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.