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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
DanFromMontreal
Helper III
Helper III

Consolidating all Measures by Project

Hello dear community,

I'm trying to use PowerQuery to group all my "Measure" that are in different rows by "Projet.

 

My table has 2 columns

 

Project     Measure

P1            A

P1            B

P1            C

P2            B

P3            C

P3            D

 

My output  should still be in 2 columns but the measure consolidated like this...

Project         Measure

P1                A, B, C

P2                B

P3                C, D

 

How do I proceed???

Thank for any help.

1 ACCEPTED SOLUTION
KNP
Super User
Super User

Hi @DanFromMontreal,

 

See if you can apply the below code to your scenario.

 

let
    Source = Table.FromRows(
        Json.Document(
            Binary.Decompress(
                Binary.FromText("i45WCjBU0lFyVIrVgTKdEExnCNMIIWqMEAUxXZRiYwE=", BinaryEncoding.Base64), 
                Compression.Deflate
            )
        ), 
        let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Project = _t, Measure = _t]
    ),
    GroupedRows = Table.Group(
        Source, 
        {"Project"}, 
        {{"all", each _, type table [Project = nullable text, Measure = nullable text]}}
    ),
    Custom1 = Table.AggregateTableColumn(
        GroupedRows, 
        "all", 
        {{"Measure", each Text.Combine(List.Transform(_, Text.From), ","), "Measure"}}
    )
in
    Custom1

 

 

Have I solved your problem?
Please click Accept as Solution so I don't keep coming back to this post, oh yeah, others may find it useful also ;).
chrome-9xf-Zagzel-B

If you found this post helpful, please give Kudos.
It gives me a sense of instant gratification and, if you give me Kudos enough times, magical unicorns will appear on your screen.
If you find my signature vaguely amusing, please give Kudos.
KIfp67uy-Sr
Proud to be a Super User!PBI-Super-User-Rank-30x30-1x

View solution in original post

6 REPLIES 6
DanFromMontreal
Helper III
Helper III

Hi @KNP ,

Today, I've spent quiet some time to trying to understand how my original table was encoded in JSON using this code

Source = Table.FromRows(
        Json.Document(
            Binary.Decompress(
                Binary.FromText("i45WCjBU0lFyVIrVgTKdEExnCNMIIWqMEAUxXZRiYwE=", BinaryEncoding.Base64), 
                Compression.Deflate
            )
        ), 
        let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Project = _t, Measure = _t]
    ),

 Reviewed many youtube video but none of them was clear enough to teach me how to take any Excel table and encode it so I can embed it in an example - just like you did.

Could you refer me to some documentation so I can learn this nice trick of yours.

 

Regards

Hey @DanFromMontreal,

 

It is just copying and pasting the data into the 'Enter data' section.

I've put together a quick video showing the process.

In the case of your table, I needed to do some tidy up and then copy and paste again. Data doesn't always copy well from this site.

Edited link: https://youtu.be/blUIzbu9l0w (no sound)

 

Have I solved your problem?
Please click Accept as Solution so I don't keep coming back to this post, oh yeah, others may find it useful also ;).
chrome-9xf-Zagzel-B

If you found this post helpful, please give Kudos.
It gives me a sense of instant gratification and, if you give me Kudos enough times, magical unicorns will appear on your screen.
If you find my signature vaguely amusing, please give Kudos.
KIfp67uy-Sr
Proud to be a Super User!PBI-Super-User-Rank-30x30-1x

Wow.

The video explained perfectly what needed to be done.

Thank you.

 

Daniel

KNP
Super User
Super User

Hi @DanFromMontreal,

 

See if you can apply the below code to your scenario.

 

let
    Source = Table.FromRows(
        Json.Document(
            Binary.Decompress(
                Binary.FromText("i45WCjBU0lFyVIrVgTKdEExnCNMIIWqMEAUxXZRiYwE=", BinaryEncoding.Base64), 
                Compression.Deflate
            )
        ), 
        let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Project = _t, Measure = _t]
    ),
    GroupedRows = Table.Group(
        Source, 
        {"Project"}, 
        {{"all", each _, type table [Project = nullable text, Measure = nullable text]}}
    ),
    Custom1 = Table.AggregateTableColumn(
        GroupedRows, 
        "all", 
        {{"Measure", each Text.Combine(List.Transform(_, Text.From), ","), "Measure"}}
    )
in
    Custom1

 

 

Have I solved your problem?
Please click Accept as Solution so I don't keep coming back to this post, oh yeah, others may find it useful also ;).
chrome-9xf-Zagzel-B

If you found this post helpful, please give Kudos.
It gives me a sense of instant gratification and, if you give me Kudos enough times, magical unicorns will appear on your screen.
If you find my signature vaguely amusing, please give Kudos.
KIfp67uy-Sr
Proud to be a Super User!PBI-Super-User-Rank-30x30-1x

Thank you sooooo much KNP.

Does the trick.

I'll need to investigate how to created your JSON file.  Sweet 😉

You're welcome.

The JSON code in the source step is the result of copy/paste data into the 'Enter data' section in Power Query.

Have I solved your problem?
Please click Accept as Solution so I don't keep coming back to this post, oh yeah, others may find it useful also ;).
chrome-9xf-Zagzel-B

If you found this post helpful, please give Kudos.
It gives me a sense of instant gratification and, if you give me Kudos enough times, magical unicorns will appear on your screen.
If you find my signature vaguely amusing, please give Kudos.
KIfp67uy-Sr
Proud to be a Super User!PBI-Super-User-Rank-30x30-1x

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!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

December 2024

A Year in Review - December 2024

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

Top Kudoed Authors