Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
wolfy_
Helper I
Helper I

transform 1 column in 2 columns

Hi,

 

Is the a way to transform 1 column in 2 colunms every now and then value?

 

1column2columns.png

 

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

 

 

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

 

 

View solution in original post

3 REPLIES 3
dearwatson
Continued Contributor
Continued Contributor

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

2columns.png

 

But the result after pivot is not the expected

 

pivot.png

 

 

error_pivot.png

 

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.

 

 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors