Forum Discussion
Help with Table conversion
- 6 years ago
Hi alexdr ,
I'm providing a solution below that covers your request, but like to add warning: The table you're requesting here is not suitable for a data model. The nature of the Power BI (or Power Pivot) data models assume that the items/fields/columns of the rows/records of your table have a relation / belong to each other.
Please paste the code below in the advanced editor and follow the steps.
It groups the table on "Store Key" and separates out all rows for each Store Key.
Then it grabs just the "Product ID"-values and creates a new table from it (Table.FromColumns) where the values are arranged columns-wise.
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUXL0VYrViVYyQjCNEUwTBNMUwTRDMEEmuDjDtUGZplBmLAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [#"Product ID" = _t, #"Store Key" = _t]), GroupOnStoreIdToSeparateOutValues = Table.Group(Source, {"Store Key"}, {{"All Rows", each _, type table [Product ID=text, Store Key=text]}}), SelectJustProductIDColumn = Table.AddColumn(GroupOnStoreIdToSeparateOutValues, "Product ID Columns", each [All Rows][Product ID]), ArrangeColumnWise = Table.FromColumns( SelectJustProductIDColumn[Product ID Columns], SelectJustProductIDColumn[Store Key] ) in ArrangeColumnWise
Hi alexdr ,
I'm providing a solution below that covers your request, but like to add warning: The table you're requesting here is not suitable for a data model. The nature of the Power BI (or Power Pivot) data models assume that the items/fields/columns of the rows/records of your table have a relation / belong to each other.
Please paste the code below in the advanced editor and follow the steps.
It groups the table on "Store Key" and separates out all rows for each Store Key.
Then it grabs just the "Product ID"-values and creates a new table from it (Table.FromColumns) where the values are arranged columns-wise.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUXL0VYrViVYyQjCNEUwTBNMUwTRDMEEmuDjDtUGZplBmLAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [#"Product ID" = _t, #"Store Key" = _t]),
GroupOnStoreIdToSeparateOutValues = Table.Group(Source, {"Store Key"}, {{"All Rows", each _, type table [Product ID=text, Store Key=text]}}),
SelectJustProductIDColumn = Table.AddColumn(GroupOnStoreIdToSeparateOutValues, "Product ID Columns", each [All Rows][Product ID]),
ArrangeColumnWise = Table.FromColumns( SelectJustProductIDColumn[Product ID Columns], SelectJustProductIDColumn[Store Key] )
in
ArrangeColumnWise
Hi ImkeF,
Thank you so much for the help.
I had a bit of tough time transform it in my advanced editor, as having related source, I needed to change.
but with a bit of tweaking it worked! Thank you so much!
I am pretty sure, you were correct and it won't work, as I won't be able to address many relationships to this table due to the way Power BI works, but it is still really nice to see how it works!
I am wishing you a nice day ahead, and hope you and your family will all stay safe during this time of uncertaincy!
Kind Regards,
Alex