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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
GJDealogic
Frequent Visitor

Group a table, Concatennate ans sum

Hi 

 

Give a granula table like this

 

Region     Product           Company      Value

EMEA       Salt                  SaltyCo        100

EMEA       Vinegar           VinCo           350

APAC       Red Sauce       RedCo          400

APAC       Brown Sauce    Brco            450

 

How can I group to this

 

Region    Product                               Company               Value

EMEA      Salt, Vinegar                       SaltyCo, VinCo         450 

APAC      Red Sauce, Brown Sauce    RedCo,Brco              850

 

Simple in SQL, tough in PBI (for me)

 

PLease help if you can

 

Rgds

Gary

 

 

2 ACCEPTED SOLUTIONS
edhans
Super User
Super User

use measures like this:

 

Companies = 
CONCATENATEX(
    'Grouping',
    'Grouping'[Company],", "
)


Products = 
CONCATENATEX(
    'Grouping',
    'Grouping'[Product], ", "
)

 

Returns this:

2020-06-03 10_57_02-Untitled - Power BI Desktop.png

 

See this PBIX file for full details.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

View solution in original post

Hi @GJDealogic 

If you want to do it in Power Query, paste this in a blank query to see the steps:

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcvV1dVTSUQpOzCmBUpXO+UCWoYGBUqwOXD4sMy81PbEIwgIrMDaFKHAMcHQGcoNSUxSCE0uTUyFssBITAxQlTkX55XlwRU5FyWA1IGNiAQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Region = _t, Product = _t, Company = _t, Value = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Region", type text}, {"Product", type text}, {"Company", type text}, {"Value", Int64.Type}}),

    #"Grouped Rows" = Table.Group(#"Changed Type", {"Region"}, {{"Product", each Text.Combine([Product], ", "), type text},{"Company", each Text.Combine([Company], ", "), type text}, {"Value", each List.Sum([Value]), type number}})
in
    #"Grouped Rows"

 

 

Please mark the question solved when done and consider giving kudos if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

View solution in original post

3 REPLIES 3
edhans
Super User
Super User

use measures like this:

 

Companies = 
CONCATENATEX(
    'Grouping',
    'Grouping'[Company],", "
)


Products = 
CONCATENATEX(
    'Grouping',
    'Grouping'[Product], ", "
)

 

Returns this:

2020-06-03 10_57_02-Untitled - Power BI Desktop.png

 

See this PBIX file for full details.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

This looks great.

Thank you.

Alas I cannot open the pbix as it from a version greater than mine. But I'll try with the formulas anyway (When I learn where to put them)

Gary

Hi @GJDealogic 

If you want to do it in Power Query, paste this in a blank query to see the steps:

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcvV1dVTSUQpOzCmBUpXO+UCWoYGBUqwOXD4sMy81PbEIwgIrMDaFKHAMcHQGcoNSUxSCE0uTUyFssBITAxQlTkX55XlwRU5FyWA1IGNiAQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Region = _t, Product = _t, Company = _t, Value = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Region", type text}, {"Product", type text}, {"Company", type text}, {"Value", Int64.Type}}),

    #"Grouped Rows" = Table.Group(#"Changed Type", {"Region"}, {{"Product", each Text.Combine([Product], ", "), type text},{"Company", each Text.Combine([Company], ", "), type text}, {"Value", each List.Sum([Value]), type number}})
in
    #"Grouped Rows"

 

 

Please mark the question solved when done and consider giving kudos if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.

Top Solution Authors