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
Anonymous
Not applicable

Calculating mode of a measure

Hi.

 

I'm trying to calculate the mode off of a measure. The problem is that the measure is calculated off a user selceted time period.

 

e.g. The measure creates the following totals based on a user selected period of 6 days:

 

Day 1       Day 2       Day 3       Day 4       Day 5       Day 6

  2              4              7              7              3              4

 

I then need the mode of this series, which in this example would be 7.

 

Interested in any ideas.

 

Thanks.

1 ACCEPTED SOLUTION
OwenAuger
Super User
Super User

Hi @Anonymous

 

Here are a couple of possible patterns adapted from DAX Patterns - Mode
(the pattern on DAX Patterns calculates the mode of a physical table column):

 

Mode of Measure by Granularity Column =
MINX (
    TOPN (
        1,
        SUMMARIZE (
            ADDCOLUMNS ( VALUES ( <Granularity Column> ), "Measure", <Measure> ),
            <Measure>,
            "Frequency", DISTINCTCOUNT ( <Granularity Column> )
        ),
        [Frequency]
    ),
    [Measure]
)
Mode of Measure by Granularity Column v2 =
MINX (
    TOPN (
        1,
        GROUPBY (
            ADDCOLUMNS ( VALUES ( <Granularity Column> ), "Measure", <Measure> ),
            [Measure],
            "Frequency", SUMX ( CURRENTGROUP (), 1 )
        ),
        [Frequency]
    ),
    [Measure]
)

In your case, replace <Measure> with your measure and <Granularity Column> with the Day column.

 

The MINX is an arbitrary tie-breaker. Could equally be MAXX.

 

Does that work for you?


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn

View solution in original post

5 REPLIES 5
OwenAuger
Super User
Super User

Hi @Anonymous

 

Here are a couple of possible patterns adapted from DAX Patterns - Mode
(the pattern on DAX Patterns calculates the mode of a physical table column):

 

Mode of Measure by Granularity Column =
MINX (
    TOPN (
        1,
        SUMMARIZE (
            ADDCOLUMNS ( VALUES ( <Granularity Column> ), "Measure", <Measure> ),
            <Measure>,
            "Frequency", DISTINCTCOUNT ( <Granularity Column> )
        ),
        [Frequency]
    ),
    [Measure]
)
Mode of Measure by Granularity Column v2 =
MINX (
    TOPN (
        1,
        GROUPBY (
            ADDCOLUMNS ( VALUES ( <Granularity Column> ), "Measure", <Measure> ),
            [Measure],
            "Frequency", SUMX ( CURRENTGROUP (), 1 )
        ),
        [Frequency]
    ),
    [Measure]
)

In your case, replace <Measure> with your measure and <Granularity Column> with the Day column.

 

The MINX is an arbitrary tie-breaker. Could equally be MAXX.

 

Does that work for you?


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn
Anonymous
Not applicable

Hi @OwenAuger

 

I've tried this formula with mi data set and it is not working...

 

I'm trying to find the most frequent average buying price of an antricle per store.

Once I introduce the stores to the table I get the same average price per store as the most frequent one...

 

And I can't make the deviation.

Could you please help me out?

 

THX

Anonymous
Not applicable

Thanks for the assist Owen.

 

Solution seems simple now I think about it. Teach me for trying to do this at 11PM at night 🙂

 

 

mpo
Helper II
Helper II

Hello,

 

You could try adding a date-value table just for this.

For example, in Power Query, create a table with unique dates from your existing table.

Then add calculated column with the calc of your measure,

Then getting mode should be trivial.

KHorseman
Community Champion
Community Champion

@Anonymous http://www.daxpatterns.com/statistical-patterns/#mode





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

Proud to be a Super User!




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