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 / How to set a variable/...
Power Apps
Answered

How to set a variable/collection in ForAll function?

(0) ShareShare
ReportReport
Posted on by 64

I have a ForAll function, and I was trying to set a variable inside that, if a condition is true. Something like this:

ForAll(...., If(.... , Set(Variable, true), Set(Variable, false) ))

I already realized that is not possible to set a variable inside a ForAll function, so I am trying to do that with a collection.

I've created a collection the same I was trying to set the variable:

ForAll(...., If(.... , Collect(Collection, {Boolean: true}), Collect(Collection, {Boolean: false})))

Now I have to check if the last record is true or false, and I can't figure out a way to do that, since I can't compare a Record with a Boolean.

I created a new collection (Collect(CollectionTF, {Boolean: true}) to compare last records, but I don't know how to do that. I'm getting "These types can't be compared: Record, Record".

Is there a way to compare just last rows of these two collections' columns?

Or, is there a better way to get  information (true or false) from within a ForAll function?

 

Thank you!!

Categories:
  • Verified answer
    CNT Profile Picture
    10,921 Super User 2024 Season 1 on at

    @gasilva8

    You can check like this,

    If(true in ShowColumns(Collection, "Boolean"), do whatever)

    Remember to clear the Collection every time, so that you will have only one record in it.

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

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 342 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 283

#3
Mohsin Ali Profile Picture

Mohsin Ali 221

Last 30 days Overall leaderboard