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 / 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:
I have the same question (0)
  • 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

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 765 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 272

Last 30 days Overall leaderboard