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
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
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.