cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
krickard
Level: Powered On

Where clause equivalent in Power Apps for Filter

I'm struggling with attempting to write the PA equivalent of a SQL where clause. In this Bold line below I want to flag records to be deleted in TempOptions that have the same QID as a parent record in TempQuestions that has already been marked with the delete flag. PA doesn't like using Filter with =. 

 

Is there a way to filter the multiple records in TempOptions and flag them based on the matching the QID and delete flag from another table (TempQuestions)? 

 

Patch(TempQuestions, LookUp(TempQuestions, QuestionText = ThisItem.Question),{Delete: 1}); ForAll(TempQuestions,Patch(TempOptions, First(Filter(TempOptions, QID = TempQuestions.QID && TempQuestions.Delete = 1)),{Delete: 1})); Remove(TempQuestions,Filter(TempQuestions, Delete > 0)); Remove(TempOptions,Filter(TempOptions, Delete > 0)); Patch(QuestionPool,ThisItem,{Loaded: 0});

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User
Super User

Re: Where clause equivalent in Power Apps for Filter

@krickard

To find all of the records we need to update within TempOptions we can use this code

Filter(TempOptions, QID in Filter(TempQuestions, Delete =1).QID)


But to actually update them we can do this

UpdateIf(
    TempOptions,
    QID in Filter(TempQuestions, Delete =1).QID),
    {Delete: 1}
)


---
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."

View solution in original post

2 REPLIES 2
Highlighted
Super User
Super User

Re: Where clause equivalent in Power Apps for Filter

@krickard

To find all of the records we need to update within TempOptions we can use this code

Filter(TempOptions, QID in Filter(TempQuestions, Delete =1).QID)


But to actually update them we can do this

UpdateIf(
    TempOptions,
    QID in Filter(TempQuestions, Delete =1).QID),
    {Delete: 1}
)


---
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."

View solution in original post

krickard
Level: Powered On

Re: Where clause equivalent in Power Apps for Filter

Thanks @mdevaney it works. 

Helpful resources

Announcements
New Ranks and Rank Icons in April

'New Ranks and Rank Icons in April

Read the announcement for more information!

Better Together’ Contest Finalists Announced!

'Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Join THE global Microsoft Power Platform event series

Attend for two days of expert-led learning and innovation on topics like AI and Analytics, powered by Dynamic Communities

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

thirdimage

Community Summit North America

Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (10,421)