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 / Variable as a column u...
Power Apps
Answered

Variable as a column using Patch

(0) ShareShare
ReportReport
Posted on by 302

Hello there!

I am having a Checklist app that loads in an x amount of questions in a gallery. I am then having a toggle at each question with yes/no. 

 

Now I have a SharePoint list with 20 columns (as 20 questions is the max). They're named;    Vraag1, Vraag2, Vraag3, etc.

Now how can I choose a certain column based on which question's toggle is changed? 

I tried to set a variable like this;

Set(vraagnr; "Vraag" && ThisItem.Volg_x0020_nr && "Akkoord")

And then use vraagnr in the Patch formula, but it just says it doesn't know the column vraagnr. 

How can I accomplish what I am looking for?

Categories:
  • BCLS776 Profile Picture
    8,994 Moderator on at

    You're running into one of the limitations of Power Apps that keep it much lower in codebase than one of the javascript libraries/frameworks - you can't dynamically assign column names in this way.

     

    Your data structure is leading you to want to do this: putting each question's result in its own column. This also makes it difficult to maintain your app - any change to the number or structure of checklist questions means a significant change to your app.

     

    Instead, add in another table or two. One table has all your possible questions, and another is a response table that associates the question & response with a unique checklist ID. You'll probably need a table of checklists that contains an ID, who performed the checks, and the date on which it was done. It may seem like extra work, but your tables get smaller, and more importantly, you query for rows that match certain values, not by trying to find the desired column name.

     

    Hope that helps,

    Bryan

  • Verified answer
    efeewfew Profile Picture
    302 on at

    Thank you for your help @BCLS776 

    I've now done it the current way;

    I have given the Checklist questions an ID and on the OnSelect, I set a variable equal to the ID. Then I just have a switch statement to check what question has been clicked and based on that, I patch. 

    Example;

    If(
     geklikteVraagNR = "1";
     Patch(
     OpleverChecklistProgress;
     LookUp(OpleverChecklistProgress; UniekNummer = gekozenOrder);
     {
     Vraag1Akkoord: Toggle2.Value
     } 
     );
     geklikteVraagNR = "2";
     Patch(
     OpleverChecklistProgress;
     LookUp(OpleverChecklistProgress; UniekNummer = gekozenOrder);
     {
     Vraag2Akkoord: Toggle2.Value
     } 
     )
    )


    Appriciate the help! This will do @BCLS776 

  • efeewfew Profile Picture
    302 on at

    -Deleted-

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
11manish Profile Picture

11manish 402 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 328

#3
WarrenBelz Profile Picture

WarrenBelz 296 Most Valuable Professional

Last 30 days Overall leaderboard