cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
krickard
Helper III
Helper III

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
mdevaney
Super User
Super User

@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
mdevaney
Super User
Super User

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

Thanks @mdevaney it works. 

Helpful resources

Announcements
Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Super User 2 - 2022 Congratulations

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Government Carousel

New forum: GCC, GCCH, DoD - Federal App Makers (FAM)

In response to the unique and evolving requirements of the United States public sector, Microsoft has created Power Apps US Government.

Users online (2,139)