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

Did you hear? There's a new SQL AI Developer certification (DP-800). Start preparing now and be one of the first to get certified. Register now

Reply
Anonymous
Not applicable

Dynamic headers

Morning,

I have a merge query and want to expand all the columns bar one, but some of the column headers are likely to change so it needs to be somewhat dynamic. 

I saw one way to expand all columns dynamically is to input two lines like this:

 

step2 = Table.AddColumn(#"step1", "Custom", each Table.ColumnNames ( Table.Combine ( #"step 1"[Transform File] ) )),

step 3= Table.ExpandTableColumn ( #"step 1", "PN Rank", step2 ),

 

But I want step2 to create a list minus one column. Is this possible? for example if it was to create the column names table but i wanted it to remove the column "part number" is there a way to do something like:


step2 = Table.AddColumn(#"step1", "Custom", each Table.ColumnNames ( Table.Combine ( #"step 1"[Transform File] Except [part number] ) )),

Thanks.

 

 

 

2 REPLIES 2
AlexisOlson
Super User
Super User

Assume the table you merged in is called Table2. Then you can define the columns you want from this table and then use that list in your expansion step.

ColsToExpand = List.Select(Table.ColumnNames(Table2), each _ <> "UnwantedColumnName" ),
#"Expanded Column" = Table.ExpandTableColumn(#"Merged Queries", "Table2", ColsToExpand)

You'll need to adjust the table names and references as appropriate for your situation.

Daryl-Lynch-Bzy
Community Champion
Community Champion

Hi @Anonymous - try breaking this down into more steps so you can apply a filter to the list of Column Names to remove the unwanted column.  It you look something like this:

 

Source = ABC with Nested Table,
ColumnNames = Table.ColumnNames(Source, Nested Table),
Filter = Table.SelectRows(ColumnNames, "Column1", each filter condition),
list = Filter[Column1],
Expand = Table.ExpandColumns( Source, "Nested Table", list )

 

 

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon & SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.