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
pakovic
Helper I
Helper I

transform table

Hello everyone, thank you very much for reading my post. I am trying to transform this table.

 

I have a table with data that looks like this:

pakovic_0-1613732581574.png

 

Is it possible to transform the table so that it is displayed like this?

pakovic_1-1613732656760.png

attached pbix file in case someone could help me.

https://www.dropbox.com/s/2dmy8303ob6stqb/example.pbix?dl=0

 

thank you all in advance.

1 ACCEPTED SOLUTION
v-henryk-mstf
Community Support
Community Support

Hi @pakovic ,


According to your needs, I did a test in power query, and the following results can be used as a reference:

let
    Origen = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("fVA9C8IwEP0rR+YKySWnrsVJqEZoFykdOhQUWhXs/8crNfXQmIwv795XXStnNT8DK9j5wyk/nsGoTKkmq5XfF0Baw9AzYpi1oBt6oxjQ6j62PZRt3z2hvFwfQ3cbgXWZY+XlJDOfUkyP0nL4N4gV4JIZBYj0KZKysExZB4qv8gLCQnIfFyjzJ4r5MDof2/9GsekobhqEIr1MdFBMq5E0FMW+s28nx+YF", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Description = _t, Euro = _t]),
    #"Tipo cambiado" = Table.TransformColumnTypes(Origen,{{"Description", type text}, {"Euro", Int64.Type}}),
    Custom1 = Table.SelectRows(#"Tipo cambiado",each Text.Start([Description],5)<>"TOTAL"),
    #"Added Custom" = Table.AddColumn(Custom1, "Customer", each if Text.Contains([Description], "COMPANY") then [Description] else null),
    #"Filled Down" = Table.FillDown(#"Added Custom",{"Customer"}),
    #"Filtered Rows" = Table.SelectRows(#"Filled Down", each ([Euro] <> null)),
    Custom2 = Table.AddColumn(#"Filtered Rows", "Sales Shipment", each if Text.Contains([Description],"Sales Shipment")
then [Description]
else null),
    #"Filled Up" = Table.FillUp(Custom2,{"Sales Shipment"}),
    Custom3 = Table.SelectRows(#"Filled Up",each Text.Start([Description],5)<>"Total"),
    #"Reordered Columns" = Table.ReorderColumns(Custom3,{"Customer", "Sales Shipment", "Description", "Euro"}),
    #"Renamed Columns" = Table.RenameColumns(#"Reordered Columns",{{"Euro", "Item"}}),
    Custom4 = Table.TransformColumns(#"Renamed Columns",{"Sales Shipment",each Text.End(_,3)})
in
    Custom4

v-henryk-mstf_0-1614065812361.png

 

Here is the sample pbix file.


If the problem is still not resolved, please provide detailed error information and let me know immediately. Looking forward to your reply.


Best Regards,
Henry


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-henryk-mstf
Community Support
Community Support

Hi @pakovic ,


According to your needs, I did a test in power query, and the following results can be used as a reference:

let
    Origen = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("fVA9C8IwEP0rR+YKySWnrsVJqEZoFykdOhQUWhXs/8crNfXQmIwv795XXStnNT8DK9j5wyk/nsGoTKkmq5XfF0Baw9AzYpi1oBt6oxjQ6j62PZRt3z2hvFwfQ3cbgXWZY+XlJDOfUkyP0nL4N4gV4JIZBYj0KZKysExZB4qv8gLCQnIfFyjzJ4r5MDof2/9GsekobhqEIr1MdFBMq5E0FMW+s28nx+YF", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Description = _t, Euro = _t]),
    #"Tipo cambiado" = Table.TransformColumnTypes(Origen,{{"Description", type text}, {"Euro", Int64.Type}}),
    Custom1 = Table.SelectRows(#"Tipo cambiado",each Text.Start([Description],5)<>"TOTAL"),
    #"Added Custom" = Table.AddColumn(Custom1, "Customer", each if Text.Contains([Description], "COMPANY") then [Description] else null),
    #"Filled Down" = Table.FillDown(#"Added Custom",{"Customer"}),
    #"Filtered Rows" = Table.SelectRows(#"Filled Down", each ([Euro] <> null)),
    Custom2 = Table.AddColumn(#"Filtered Rows", "Sales Shipment", each if Text.Contains([Description],"Sales Shipment")
then [Description]
else null),
    #"Filled Up" = Table.FillUp(Custom2,{"Sales Shipment"}),
    Custom3 = Table.SelectRows(#"Filled Up",each Text.Start([Description],5)<>"Total"),
    #"Reordered Columns" = Table.ReorderColumns(Custom3,{"Customer", "Sales Shipment", "Description", "Euro"}),
    #"Renamed Columns" = Table.RenameColumns(#"Reordered Columns",{{"Euro", "Item"}}),
    Custom4 = Table.TransformColumns(#"Renamed Columns",{"Sales Shipment",each Text.End(_,3)})
in
    Custom4

v-henryk-mstf_0-1614065812361.png

 

Here is the sample pbix file.


If the problem is still not resolved, please provide detailed error information and let me know immediately. Looking forward to your reply.


Best Regards,
Henry


If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Wow! Thank you very much. It works very well !!

amitchandak
Super User
Super User

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.