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
navedkhan
Helper III
Helper III

Urgently needs help in "Transposing Columns to rows"

Hi Guys - i am in URGENT need to do the following;

Capture.PNG

Requirement: move columns (measure-2 & comments) as shown above to append beneath a given column [measure-1 & comments] and fill dates for the said no. of entries being added (reason being both columns contain same information) and hence need to be clubbed in one.

 

Any help anyone please?

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hello-

 

  One option is to duplicate your table.  In one table, remove all but date, measure-1, and comments-1 (renamed to comments-1).

In the other remove all but date, measure-2 and comments-2(renamed comments-2).

 

After this, rename: measure-1 to measure and measure-2 to measure.  Rename comments-1 to comments and comments-2 to comments.

 

Select Append queries.  They should append as 3 columns: date, measure, and comments.

 

Jared

View solution in original post

2 REPLIES 2
mussaenda
Super User
Super User

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjLQN7DUNzIwtFTSUXLMKchIBNLJKcUpSNzU8tTyIqVYHTTVTqklEMVp6UDKPTE3F8RNLE5MSUvFVA2TTytOASpBaC9KTS8qSwbah6EDgqIgyrLSM9KUYmMB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [date = _t, #"measure-1" = _t, #"comments-1" = _t, #"measure-2" = _t, #"comments-2" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"date", type date}, {"measure-1", type text}, {"comments-1", type text}, {"measure-2", type text}, {"comments-2", type text}}),
    #"Removed Columns" = Table.RemoveColumns(#"Changed Type",{"measure-1", "comments-1"}),
    #"Renamed Columns" = Table.RenameColumns(#"Removed Columns",{{"measure-2", "measure"}, {"comments-2", "comments"}})
in
    #"Renamed Columns"
let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjLQN7DUNzIwtFTSUXLMKchIBNLJKcUpSNzU8tTyIqVYHTTVTqklEMVp6UDKPTE3F8RNLE5MSUvFVA2TTytOASpBaC9KTS8qSwbah6EDgqIgyrLSM9KUYmMB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [date = _t, #"measure-1" = _t, #"comments-1" = _t, #"measure-2" = _t, #"comments-2" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"date", type date}, {"measure-1", type text}, {"comments-1", type text}, {"measure-2", type text}, {"comments-2", type text}}),
    #"Removed Columns" = Table.RemoveColumns(#"Changed Type",{"measure-2", "comments-2"}),
    #"Renamed Columns" = Table.RenameColumns(#"Removed Columns",{{"measure-1", "measure"}, {"comments-1", "comments"}}),
    #"Appended Query" = Table.Combine({#"Renamed Columns", #"Table (3)"})
in
    #"Appended Query"

2019_09_28_16_28_51_Untitled_Power_Query_Editor.png

 

Anonymous
Not applicable

Hello-

 

  One option is to duplicate your table.  In one table, remove all but date, measure-1, and comments-1 (renamed to comments-1).

In the other remove all but date, measure-2 and comments-2(renamed comments-2).

 

After this, rename: measure-1 to measure and measure-2 to measure.  Rename comments-1 to comments and comments-2 to comments.

 

Select Append queries.  They should append as 3 columns: date, measure, and comments.

 

Jared

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.