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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Use variable in collec...
Power Apps
Answered

Use variable in collection instead of column name

(0) ShareShare
ReportReport
Posted on by 34

I have a collection of 70 items, and I want to use the same text_input to update them all. Currently, on my save button on select I am using a if statement which is very long.

 

If(
temp_category = "boundary_hoarding",
Patch(
temp_site_weekly_inspection,
First(temp_site_weekly_inspection),
{boundary_hoarding_comment: view_comment_text_input.Text}
);,
temp_category = "welfare_facilities",
Patch(
temp_site_weekly_inspection,
First(temp_site_weekly_inspection),
{welfare_facilities_comment: view_comment_text_input.Text}
);
);

 

However, I was wondering if it possible to use my temp_category value instead of column name to update the right field.

 

Patch(
temp_site_weekly_inspection,
First(temp_site_weekly_inspection),
{temp_category: view_comment_text_input.Text}

 

But, I get the following error "The function 'Patch' has some invalid argument.

 

Thanks in advance for any suggestions.

Categories:
I have the same question (0)
  • Verified answer
    BCLS776 Profile Picture
    8,994 Moderator on at

    Unfortunately, Power Apps does not support dynamic access to column names through variables - the service needs to read the schema of the table & column prior to runtime to work correctly.

     

    If you are finding this code cumbersome to use in your app, consider moving it to a Power Automate flow to perform this update. You can pass a single argument to a flow, but use that argument multiple times within your flow.

     

    Hope that helps,

    Bryan

  • hadimarashy Profile Picture
    34 on at

    Thank you for your help, I am going to use a flow.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 377 Most Valuable Professional

#2
11manish Profile Picture

11manish 165 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 110 Super User 2026 Season 2

Last 30 days Overall leaderboard