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
mglomb
Frequent Visitor

Merging Rows and Columns

I have a database where the main ID is the core (repeated) value, and each additional column has its own data.

 

I want to merge rows and columns in a way that each row has all the columns filled, and I can have a single view of each core ID.

 

What is the best way to do that?

1 ACCEPTED SOLUTION
v-yalanwu-msft
Community Support
Community Support

Hi, @mglomb ;

You could group by in power query .

vyalanwumsft_0-1635148658703.png

The final output is shown below:

vyalanwumsft_1-1635148682559.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQ0VNJRMjTQNzLUNzIwAnEgyCkxL1EhL1EpVgemCKIOpMzAEKEGXQkQWepbwMxCUmFkbAKWA9kFkQSykS31L0rMS09FUgtBFvrGMEVIKkxMzaDuNkB1d0BqYnIGmhJDrEpiAQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Id = _t, Date1 = _t, #"Date 2" = _t, #"Date 3" = _t, Description = _t]),
    #"Changed Type with Locale" = Table.TransformColumnTypes(Source, {{"Date1", type date}, {"Date 2", type date}, {"Date 3", type date}}, "en-US"),
    #"Grouped Rows" = Table.Group(#"Changed Type with Locale", {"Id"}, {{"Date1", each List.Max([Date1]), type nullable date}, {"Date2", each List.Max([Date 2]), type nullable date}, {"Date3", each List.Max([Date 3]), type nullable date}, {"Descripition", each List.Max([Description]), type nullable text}})
in
    #"Grouped Rows"

Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-yalanwu-msft
Community Support
Community Support

Hi, @mglomb ;

You could group by in power query .

vyalanwumsft_0-1635148658703.png

The final output is shown below:

vyalanwumsft_1-1635148682559.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQ0VNJRMjTQNzLUNzIwAnEgyCkxL1EhL1EpVgemCKIOpMzAEKEGXQkQWepbwMxCUmFkbAKWA9kFkQSykS31L0rMS09FUgtBFvrGMEVIKkxMzaDuNkB1d0BqYnIGmhJDrEpiAQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Id = _t, Date1 = _t, #"Date 2" = _t, #"Date 3" = _t, Description = _t]),
    #"Changed Type with Locale" = Table.TransformColumnTypes(Source, {{"Date1", type date}, {"Date 2", type date}, {"Date 3", type date}}, "en-US"),
    #"Grouped Rows" = Table.Group(#"Changed Type with Locale", {"Id"}, {{"Date1", each List.Max([Date1]), type nullable date}, {"Date2", each List.Max([Date 2]), type nullable date}, {"Date3", each List.Max([Date 3]), type nullable date}, {"Descripition", each List.Max([Description]), type nullable text}})
in
    #"Grouped Rows"

Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@mglomb ,The information you have provided is not making the problem clear to me. Can you please explain with an example.
Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.
Appreciate your Kudos.

 

You can check for fill up and filldown and pivot and unpivot options in power query

Thank you for trying to help. I've drawn a simple example of what the database look and what I'm trying to achieve. Please see below:

 

Screenshot 2021-10-21 095435.jpg

 

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.