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.
Hi,
Is the a way to transform 1 column in 2 colunms every now and then value?
Columns1
2019-08-08 20:12:30.51
1F7D 09
2019-08-08 20:10:06.47
2045 09
2019-08-08 20:12:51.09
1F7E 09
2019-08-08 20:13:18.86
1FE3 09
to
columns1 columns2
2019-08-08 20:12:30.51 1F7D 09
2019-08-08 20:10:06.47 2045 09
2019-08-08 20:12:51.09 1F7E 09
2019-08-08 20:13:18.86 1FE3 09
Solved! Go to Solution.
These Pivot challenges can be solved by using an additional column to identify the pairs. This gets past the error thrown from Pivot when using 'Don't aggregate'.
Add an index column (from zero).
Add a column which identifies the pairs with each Number.IntegerDivide([Index],2)
Then delete the unneeded columns and do the pivot.
et Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("dcw7CsAwDAPQq4TMrZGdv+emlwi5/zUagqdCQINAD43hBdxu1BUnUBYNoMR+XsPzWx6HtvuPQZEpFptiOjDRxGTTeusHFpQr1Wysh83mBw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Columns1 = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Columns1", type text}}), #"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 0, 1), #"Added Custom" = Table.AddColumn(#"Added Index", "data", each Number.Mod([Index], 2)), #"Added Conditional Column" = Table.AddColumn(#"Added Custom", "Custom", each if [data] = 0 then "datetime" else "id"), #"Added Custom1" = Table.AddColumn(#"Added Conditional Column", "Custom.1", each Number.IntegerDivide([Index],2)), #"Removed Columns" = Table.RemoveColumns(#"Added Custom1",{"Index", "data"}), #"Pivoted Column" = Table.Pivot(#"Removed Columns", List.Distinct(#"Removed Columns"[Custom]), "Custom", "Columns1") in #"Pivoted Column"
It's a good technique if the data comes in a list with a consistent order.
Hi Wolfy,
this is a "pivot" challenge.
In power query create a new column that alternates the values:
column1
column2
then do a "pivot" on this new column with your original column as the value... this should give you the output you needs
Cheers
Greg
Hi,
I tried as you said
But the result after pivot is not the expected
These Pivot challenges can be solved by using an additional column to identify the pairs. This gets past the error thrown from Pivot when using 'Don't aggregate'.
Add an index column (from zero).
Add a column which identifies the pairs with each Number.IntegerDivide([Index],2)
Then delete the unneeded columns and do the pivot.
et Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("dcw7CsAwDAPQq4TMrZGdv+emlwi5/zUagqdCQINAD43hBdxu1BUnUBYNoMR+XsPzWx6HtvuPQZEpFptiOjDRxGTTeusHFpQr1Wysh83mBw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Columns1 = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Columns1", type text}}), #"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 0, 1), #"Added Custom" = Table.AddColumn(#"Added Index", "data", each Number.Mod([Index], 2)), #"Added Conditional Column" = Table.AddColumn(#"Added Custom", "Custom", each if [data] = 0 then "datetime" else "id"), #"Added Custom1" = Table.AddColumn(#"Added Conditional Column", "Custom.1", each Number.IntegerDivide([Index],2)), #"Removed Columns" = Table.RemoveColumns(#"Added Custom1",{"Index", "data"}), #"Pivoted Column" = Table.Pivot(#"Removed Columns", List.Distinct(#"Removed Columns"[Custom]), "Custom", "Columns1") in #"Pivoted Column"
It's a good technique if the data comes in a list with a consistent order.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
114 | |
99 | |
83 | |
70 | |
60 |
User | Count |
---|---|
150 | |
115 | |
104 | |
89 | |
65 |