cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
roncruiser Regular Visitor
Regular Visitor

Calculate the Count of the Mode Value for each SN Group

Source Data:

Source.JPG

 

I was able to use the list functions for each grouped table to get:

Min

Max

Mode

Average

Count

 

Column_Values.JPG

 

#"Customized" = Table.Group(#"Changed Type", "SN", {{ "Min", each List.Min([Value]), type number},
{"Max", each List.Max([Value]), type number},{"Mode", each List.Mode([Value]), type number},
{"Average", each List.Average([Value]), type number},{"Count", each List.Count([Value]), type number}},
GroupKind.Local, Comparer.OrdinalIgnoreCase)

 

List.Mode returns the value used most for each table, but what is the proper way to add another column to show the count of the mode value occurances for each table?

 

For example, adding another column showing count of the mode values:

SN      Mode_Value_Occurance

a         2      (mode value "2" occurs 2 times.)

b         4      (mode value "3" occurs 4 times.)

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support Team
Community Support Team

Re: Calculate the Count of the Mode Value for each SN Group

Hi @roncruiser ,

 

I process that by DAX here. Please refer to the formula of the calculated table.

 

Table = 
SUMMARIZE (
    Table1,
    Table1[SN],
    "min", MIN ( Table1[Value] ),
    "max", MAX ( Table1[Value] ),
    "mode", MINX (
        TOPN (
            1,
            ADDCOLUMNS (
                VALUES ( Table1[Value] ),
                "Frequency", CALCULATE ( COUNT ( Table1[Value] ) )
            ),
            [Frequency], 0
        ),
        Table1[Value]
    ),
    "average", AVERAGE ( Table1[Value] ),
    "count", COUNTROWS ( Table1 ),
    "count1", CALCULATE (
        COUNTROWS ( Table1 ),
        FILTER (
            Table1,
            Table1[Value]
                = MINX (
                    TOPN (
                        1,
                        ADDCOLUMNS (
                            VALUES ( Table1[Value] ),
                            "Frequency", CALCULATE ( COUNT ( Table1[Value] ) )
                        ),
                        [Frequency], 0
                    ),
                    Table1[Value]
                )
        )
    )
)

Capture.PNG

 

Regards,

Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
5 REPLIES 5
Super User
Super User

Re: Calculate the Count of the Mode Value for each SN Group

@roncruiser  Just want to confirm, whether you just want to show the highest occurances value only within a group or each value and it's number of occurances.



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

Proud to be a Datanaut !





Highlighted
Community Support Team
Community Support Team

Re: Calculate the Count of the Mode Value for each SN Group

Hi @roncruiser ,

 

I process that by DAX here. Please refer to the formula of the calculated table.

 

Table = 
SUMMARIZE (
    Table1,
    Table1[SN],
    "min", MIN ( Table1[Value] ),
    "max", MAX ( Table1[Value] ),
    "mode", MINX (
        TOPN (
            1,
            ADDCOLUMNS (
                VALUES ( Table1[Value] ),
                "Frequency", CALCULATE ( COUNT ( Table1[Value] ) )
            ),
            [Frequency], 0
        ),
        Table1[Value]
    ),
    "average", AVERAGE ( Table1[Value] ),
    "count", COUNTROWS ( Table1 ),
    "count1", CALCULATE (
        COUNTROWS ( Table1 ),
        FILTER (
            Table1,
            Table1[Value]
                = MINX (
                    TOPN (
                        1,
                        ADDCOLUMNS (
                            VALUES ( Table1[Value] ),
                            "Frequency", CALCULATE ( COUNT ( Table1[Value] ) )
                        ),
                        [Frequency], 0
                    ),
                    Table1[Value]
                )
        )
    )
)

Capture.PNG

 

Regards,

Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
roncruiser Regular Visitor
Regular Visitor

Re: Calculate the Count of the Mode Value for each SN Group

@PattemManohar 

 

Now, that I think about it more.  It would be move valuable to  show occurences for each value in each group with the option within the Mcode to show only the mode occurence. Showing a single value versus for all the values within the group for the sake of load times into the data model.

 

Thank you.

Community Support Team
Community Support Team

Re: Calculate the Count of the Mode Value for each SN Group

Hi @roncruiser ,

 

Did you have a chance to check my way?

 

Regards,

Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
roncruiser Regular Visitor
Regular Visitor

Re: Calculate the Count of the Mode Value for each SN Group

@v-frfei-msft 

 

I have not had that chance yet.  But I will.  Got pulled aside and tasked to something else at the moment.  This forum and the community is extremely valuable and helpful for the occasional dabbler like me.