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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
kgiboin
Helper I
Helper I

Dynamic unpivot of columns in Power Query

Hi,

I am using the function = Table.Unpivot(#"Filtered Rows1", {"x","y","z"...}, "Attribute", "Value") to unpivot a table by those selected rows.

 

However, they are input values and will change and when they change I get the error that a column header is missing.

How do I write this in a way that -instead of listing out the column headings to unpivot {"x","y","z"...}, I can select all columns beginning with column 4 to the end.  Is it doable?

Regards

1 ACCEPTED SOLUTION
ronrsnfld
Super User
Super User

Something like:

= Table.Unpivot(#"Filtered Rows1", List.RemoveFirstN(Table.ColumnNames(#"Filtered Rows1"),3), "Attribute", "Value") 

View solution in original post

2 REPLIES 2
BA_Pete
Super User
Super User

Hi @kgiboin ,

 

Flip the operation on its head: Select all the columns you DON'T want to unpivot, then go to Transform tab > Unpivot Columns (dropdown) > Unpivot OTHER columns.

 

This will generate code like this instead:

Table.UnpivotOtherColumns(previousStep, {"fixedColumnA", "fixdColumnB"}, "Attribute", "Value")

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




ronrsnfld
Super User
Super User

Something like:

= Table.Unpivot(#"Filtered Rows1", List.RemoveFirstN(Table.ColumnNames(#"Filtered Rows1"),3), "Attribute", "Value") 

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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

Top Solution Authors
Top Kudoed Authors