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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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

b         4

1 ACCEPTED SOLUTION
OwenAuger
Super User
Super User

@roncruiser 

Something like this should work (additional code in red):

 

#"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},
{"Mode_Value_Occurrence",
each let mode = List.Mode([Value]) in List.Count(List.Select([Value], each _=mode)), Int64.Type}}, GroupKind.Local, Comparer.OrdinalIgnoreCase)

Admittedly, the Mode ends up being evaluated twice for each group, but if this performs well enough I wouldn't worry about it.

 

Regards,

Owen

 


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

View solution in original post

10 REPLIES 10

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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