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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
nicplancho
Helper I
Helper I

Automate unpivoting of columns following a certain format

Hi guys,

I would like to use some kind of automation (RegEx?) to replace those manual entries by an automated format extraction for all YYYY-MM columns.

 

Here is the manual unpivoting : #"Unpivoted Only Selected Columns" = Table.Unpivot(#"Filtered Rows1", {"2022-01", "2022-02", "2022-03", "2022-04", "2022-05", "2022-06"}, "Date", "Raw hours")

 

Do you have any clue regarding the way I may automate this please ?

 

NB: Yes I may also use Table.UnpivotOtherColumns with the "fixed" columns but I believe it's not so robust and thus I am looking for another solution.

 

Thanks in advance,

Nicolas.

1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

How do you decide which columns need to be pivoted?

 

Instead of your list {"2022-01", "2022-02", "2022-03", "2022-04", "2022-05", "2022-06"}, you could write something like this

List.Select(Table.ColumnNames(#"Filtered Rows1"), each Text.StartsWith(_, "2022-"))

 But I don't know exactly what condition you actually need instead of the example I gave.

View solution in original post

2 REPLIES 2
nicplancho
Helper I
Helper I

Hi Alexis,

Thanks a lot for your support, works like a chram 🙂

 

Here is what I exactly did based on your suggestion :

 

#"PivotList" = List.Select(Table.ColumnNames(#"Filtered Rows1"), each Text.StartsWith(_, "202")),
#"Unpivoted Only Selected Columns" = Table.Unpivot(#"Filtered Rows1", #"PivotList", "Date", "Raw hours"),

AlexisOlson
Super User
Super User

How do you decide which columns need to be pivoted?

 

Instead of your list {"2022-01", "2022-02", "2022-03", "2022-04", "2022-05", "2022-06"}, you could write something like this

List.Select(Table.ColumnNames(#"Filtered Rows1"), each Text.StartsWith(_, "2022-"))

 But I don't know exactly what condition you actually need instead of the example I gave.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors
Top Kudoed Authors