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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
roncruiser
Helper V
Helper V

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
v-frfei-msft
Community Support
Community Support

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 others find it more quickly.

View solution in original post

5 REPLIES 5
v-frfei-msft
Community Support
Community Support

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 others find it more quickly.
PattemManohar
Community Champion
Community Champion

@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 PBI Community Champion




@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.

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 others find it more quickly.

@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.

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.