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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

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
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.