Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

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 w...
  • Anonymous's avatar
    Anonymous
    5 years ago

    Hi  Anonymous  ,

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

    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:

    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.