Using Power Query to get List of column names

cr731

Well-known Member
Joined
Sep 17, 2010
Messages
611
Using Power Query, what's the simplest way to get a list of the column names of a table?

My approach currently is,

- Demote headers
- transpose table
- remove all but first column

This works but feels a bit messy. Is there a better way?

Thanks
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
One way:
1. Filter and keep just One unique row
2. Unpivot --> all column headers
3. Delete the unique row (or keep it as an example)
//Ola
 
Upvote 0
One way:
1. Filter and keep just One unique row
2. Unpivot --> all column headers
3. Delete the unique row (or keep it as an example)
//Ola


This is a very useful technique. However, in PQ 365 if your unique row has a NULL in it, that column does not get listed after the 'unpivot'. You need to replace NULLS in that first row with some value and then convert it back to the NULL after the 'unpivot'.
 
Upvote 0
This is a very useful technique. However, in PQ 365 if your unique row has a NULL in it, that column does not get listed after the 'unpivot'. You need to replace NULLS in that first row with some value and then convert it back to the NULL after the 'unpivot'.

Same technique but filter and keep 0 rows. Demote headers and then transpose instead of unpivot.

But Table.ColumnNames is a quicker way to get the names.
 
Upvote 0

Forum statistics

Threads
1,213,543
Messages
6,114,237
Members
448,555
Latest member
RobertJones1986

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top