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
Anonymous
Not applicable

How to move only in row to be a column

Hi everyone,

 

I would really appreciate your help. I have this data that we get as a csv every month and it is formatted weird. I would like to use Power Query to make the "Zeitraum" a new column and the 22022 should be the values below for every row.

The 22022 in this case stands for February 2022. I would also need this field to be transformed to be 01.02.2022 (European Format, first of month so that my Calendar Table still works). 

 

Since I get updates of that csv monthly, I cannot do some sort of search an replace of the 22022 since it will change in every update. 

Michella_0-1648459839878.png

 

Thanks for your suggestions, Michaela

1 ACCEPTED SOLUTION

Replace all of that with

let
Source = Csv.Document(Parameter1,[Delimiter=";", Columns=8, Encoding=1252, QuoteStyle=QuoteStyle.None]),
ColName = Source{0}[Column1],
ColVal = Source{0}[Column2],
Custom1 = Table.AddColumn(Source, ColName, each ColVal)
in
Custom1

then do the remove rows and promote headers, then open Advanced Editor again and add

RenamedCols = Table.RenameColumns(#"Changed Type", { ColVal, ColName})

after the last step, just before the "in". Make sure to add a comma at the end of the previous line, and you'll need to change #"Changed Type" to the name of the previous step. Finally, replace the final line of the code with RenamedCols

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

Thanks John,

 

I am not as experienced in Power Query now I struggle with where to put the variables, sorry.

 

My advanced editor looks like this now:

 

let
Source = Csv.Document(Parameter1,[Delimiter=";", Columns=8, Encoding=1252, QuoteStyle=QuoteStyle.None]),
Custom1 = Table.AddColumn(Source, Source{0}[Column1], each Source{0}[Column2]),
Custom2 = Table.RenameColumns(#"Custom1", { ColVal, ColName})
in
Custom2

Replace all of that with

let
Source = Csv.Document(Parameter1,[Delimiter=";", Columns=8, Encoding=1252, QuoteStyle=QuoteStyle.None]),
ColName = Source{0}[Column1],
ColVal = Source{0}[Column2],
Custom1 = Table.AddColumn(Source, ColName, each ColVal)
in
Custom1

then do the remove rows and promote headers, then open Advanced Editor again and add

RenamedCols = Table.RenameColumns(#"Changed Type", { ColVal, ColName})

after the last step, just before the "in". Make sure to add a comma at the end of the previous line, and you'll need to change #"Changed Type" to the name of the previous step. Finally, replace the final line of the code with RenamedCols

Anonymous
Not applicable

Thanks John, that was really helpful! Have a great day 🙂

Anonymous
Not applicable

Hello @johnt75 ,

 

thanks for the reply, I am now at this point: 

Michella_0-1648463515781.png

The problem I have now is, that the header is now called 22022 and I cannot do replace since the numbers change. So the next thing I'd need to do is only rename the header of this column and I don't know how to do it without mentioning the 22022.

 

Michella_1-1648463569713.png

 

Greetings,

Michaela 

Ah, yes. You can store the values in variables like

ColName = Source{0}[Column1],
ColVal = Source{0}[Column2],
AddedCol = Table.AddColumn( Source, ColName, each ColVal),

and then after you have deleted the top row and promoted the headers, you can add

RenamedCols = Table.RenameColumns(#"Changed Type", { ColVal, ColName})
johnt75
Super User
Super User

Add a step as

Table.AddColumn(Source, Source{0}[Column1], each Source{0}[Column2])

you can then remove the top row, promote the first row to headers and do any other transformations you need to

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
Top Kudoed Authors