cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
sienna28
Post Patron
Post Patron

Execute search until no match found

Is it possible to keep running the search command until a match is not found in my collection?

I know there is no looping available in PowerApps.

I wonder if a timer could do it.

It would not matter if the whole procedure is run, but when a match is not found in the collection the timer should somehow end.

1 ACCEPTED SOLUTION

Accepted Solutions
mdevaney
Super User
Super User

@sienna28
I have an idea. It does not use any timer and it loops through all records but ensures only one record is returned.

Set(breakLoop,False);
ForAll(testCollection,
If(And(breakLoop=False, your other conditions here),
your true condition code here;
Set(breakLoop,True);
)
);

There’s also another option: you could COLLECT all the results and extract the first result using the FIRST function.

—-
Please Accept as Solution if this post answered your question so 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

@sienna28
I have an idea. It does not use any timer and it loops through all records but ensures only one record is returned.

Set(breakLoop,False);
ForAll(testCollection,
If(And(breakLoop=False, your other conditions here),
your true condition code here;
Set(breakLoop,True);
)
);

There’s also another option: you could COLLECT all the results and extract the first result using the FIRST function.

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

Thanks - unsure if this works for my scenario.

I sent a message with more details.

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Top Solution Authors
Top Kudoed Authors
Users online (1,228)