I'm relatively new to M Language and struggling to write a line of code to do what I want in Power Query. I have a table that looks like this:

https://imgur.com/a/m5XdXZX

I want to loop through each row and promote headers in the tables in the Transform File column if they meet certain criteria. Here is what I've written:

= Table.TransformColumns(#"Filtered Rows", if Table.ColumnNames(#"Filtered Rows") = {"Column1", "Column2", "Column3", "Column4", "Column5"} then {{"Transform File", each Table.PromoteHeaders(_, [PromoteAllScalars = true])}} else _)

I believe the issue is in my else statement. I'm not sure how to translate "If the current headers don't match {"Column1", "Column2", ...} then don't promote the headers and leave the table as is". Can anyone help? Thanks.

I have cross posted this here:
https://www.reddit.com/r/excel/comme...ws_in_a_table/