cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
efeewfew
Resolver I
Resolver I

Variable as a column using Patch

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?

1 ACCEPTED SOLUTION

Accepted Solutions

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 

View solution in original post

3 REPLIES 3
BCLS776
Super User
Super User

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

_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.

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 

View solution in original post

-Deleted-

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (3,211)