Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Power Query
Unanswered

Function to add columns based on a list of column names with function

(0) ShareShare
ReportReport
Posted on by 382

I'm coming back to a post post from three years ago. The question then was, how to add columns based on a list.

 

I want to go further on the solution provided:

let myFunc = ( myTable, myNewColumnList) =>

let foo = List.Accumulate(

myNewColumnList,
myTable,
(current_table, new_name) =>

if List.Contains(Table.ColumnNames( current_table), new_name)
then current_table
else Table.AddColumn(current_table, new_name, each null)

)

in foo

in myFunc

 

The solution is working fine.

 

However instead of putting a null into each row I want to use a calculated value.

 

Anytime I replace the null in the above code with something like '_ +1' I get an error. (The reference to the current record (_) alone is working). It looks like _ is recognized as a record. I cannot 'hardcode' the name of the first column because this name is not always the same (myNewColumList is passed and can be any list).

 

My question now is, how to write a formula into that function.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Leaderboard > Power Apps - Power Query

#1
mmbr1606 Profile Picture

mmbr1606 9 Super User 2025 Season 1

#2
stampcoin Profile Picture

stampcoin 7

#3
SD-13050734-0 Profile Picture

SD-13050734-0 6

Overall leaderboard

Featured topics