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 / Help needed related to...
Power Apps
Answered

Help needed related to patch code

(0) ShareShare
ReportReport
Posted on by

Hi,

 

I am trying to do a simple patch to collection with data coming from a gallery, based on an if else, however the patch is not working, below code for reference:

 

if(Dropdown2.Selected.Value = Filter_Gal.Selected.CorrectAnswer,
Patch(QCollection,LookUp(QCollection,QuestionID = Filter_Gal.Selected.QuestionID,{Score:Filter_Gal.Selected.Marks}));

 

Thanks in advance.

Categories:
I have the same question (0)
  • mdevaney Profile Picture
    29,991 Moderator on at

    @omarmahmood 
    What do you mean by 'its not working'?  What is not working about the PATCH?

  • KrishnaV Profile Picture
    5,023 on at

    Hi @omarmahmood ,

     

    I see a syntax error in your code:

    if(Dropdown2.Selected.Value = Filter_Gal.Selected.CorrectAnswer,
     Patch(QCollection,LookUp(QCollection,QuestionID = Filter_Gal.Selected.QuestionID,{Score:Filter_Gal.Selected.Marks})))

    use the above.

     

    I hope this resolved your issue if you see any challenge/need further help let me know I am always happy to help.

     

    Regards,
    Krishna
    If this post helps give a 👍 and if it solved your issue consider Accept it as the solution to help the other members find it more.

  • mdevaney Profile Picture
    29,991 Moderator on at

    @omarmahmood 

    I think @KrishnaV is correct about there being a syntax error but I think the error is in a different place.

     

    If(Dropdown2.Selected.Value = Filter_Gal.Selected.CorrectAnswer,
    Patch(QCollection,LookUp(QCollection,QuestionID = Filter_Gal.Selected.QuestionID),{Score:Filter_Gal.Selected.Marks}));

     

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

  • Verified answer
    v-qiaqi@microsoft.com Profile Picture
    Microsoft Employee on at

    Hi @omarmahmood ,

    Based on the formula you provided, do you want to update the record based on the selection from your dropdown?

    Could you please share more about your data source and your gallery configuration, I guess when you pick a selection from the Dropdown, a record will display in the gallery which contains fields like”CorrectAnswer”,”ID”,”Marks”. You want to update the Score with the selected field value.

    Please post some screenshots about your error message.

    Here is a standard formula for reference:

    If(condition,…
    Patch(
     QCollection,
     LookUp(QCollection,QuestionID = xxx),
     {
     Score: Value
     }
    )
    )

    Note: xxx is a specific value which you should specify from the gallery

    And on your side, you should add a ) to your LookUp(). @mdevaney provides a correct solution, I just do some addition on the standard formula.

    Please modify your formula as below:

    if(Dropdown2.Selected.Value = Filter_Gal.Selected.CorrectAnswer,Patch(QCollection,LookUp(QCollection,QuestionID =Filter_Gal.Selected.QuestionID),{Score:Filter_Gal.Selected.Marks}))

    Best Regards,

    Qi

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

#2
11manish Profile Picture

11manish 209 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 179

Last 30 days Overall leaderboard