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
Schnauzer77
Regular Visitor

'Group By' operators - no PRODUCT option?

Hi, the power query 'group by' function seems very similar to pivot tables in Excel, apart from one major flaw (for me). There is no option to get the PRODUCT of the values, as opposed to the sum, average, min etc. Does anyone have a workaround where by I could get the PRODUCT of a column, and group the results by values in other columns?

1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

You can use whatever function you'd like with a small tweak to the code. Do the Group By using Sum and it will generate a step that looks like this:

AlexisOlson_0-1639175588215.png

 

Edit the code in the formula bar to replace List.Sum with List.Product and it will take the product over the group instead of the sum.

 

Sample M code you can paste into your Advanced Editor:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUXIEYiOlWJ1oIAnhGYN5xkCWExCbgHkmUDlDMM8UKgfRZwaVA6qMBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, Group = _t, Value = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", Int64.Type}, {"Group", type text}, {"Value", Int64.Type}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Group"}, {{"Value", each List.Product([Value]), type nullable number}})
in
    #"Grouped Rows"

 

I use this trick with other operators too. For example, Text.Combine to concatenate text rows.

View solution in original post

2 REPLIES 2
Schnauzer77
Regular Visitor

Wow - that is so simple and the perfect solution for me. Thanks!

AlexisOlson
Super User
Super User

You can use whatever function you'd like with a small tweak to the code. Do the Group By using Sum and it will generate a step that looks like this:

AlexisOlson_0-1639175588215.png

 

Edit the code in the formula bar to replace List.Sum with List.Product and it will take the product over the group instead of the sum.

 

Sample M code you can paste into your Advanced Editor:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUXIEYiOlWJ1oIAnhGYN5xkCWExCbgHkmUDlDMM8UKgfRZwaVA6qMBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, Group = _t, Value = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", Int64.Type}, {"Group", type text}, {"Value", Int64.Type}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Group"}, {{"Value", each List.Product([Value]), type nullable number}})
in
    #"Grouped Rows"

 

I use this trick with other operators too. For example, Text.Combine to concatenate text rows.

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.