web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Function to add column...
Power Apps
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.

Categories:
I have the same question (0)

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard