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 / Can't get remove funct...
Power Apps
Answered

Can't get remove function to work with global variable

(0) ShareShare
ReportReport
Posted on by 12

Greetings everyone,

 

I have been writing an app that for the sake of simplicity defines a global variable as one of a number of possible tables.

 

it works fine in galleries and forms however when I attempt to use it in the remove function I get an error saying "the first argument of 'Remove' should be a collection"

 

my code is as follows

Remove(AFTable, Dropdown1.Selected);
Back()

 

is there any way to get this to work in a way that won't require me to change the code whenever a new option for AFTable is created?

Categories:
  • Verified answer
    v-jefferni Profile Picture
    Microsoft Employee on at

    Hi @Grisdale ,

     

    As the error message saying, Remove function only accept collection or actual table as its first argument. So, please try and use ClearCollect instead of Set to create 'AFTable'.

     

    Best regards,

  • Grisdale Profile Picture
    12 on at

    Can you explain in more detail please. I am rather inexperienced with power apps.

    from what I understand ClearCollect clears a collection completely that adds what you define in the function.

     

    Specifically how would I go about using ClearCollect to define a collection variable?

  • Verified answer
    developerAJ Profile Picture
    4,763 on at

    @Grisdale 

     

    As jefferni suggested you need to use collection clearcollect

     

    but if you still want to use the set variable probably you can let us know what is the output of AFTable and what you want to achieve by using Remove(AFTable, Dropdown1.Selected); from that we could provide if there is another possible way.

     

    Please click Accept as solution and Thumbs Up. if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

  • Grisdale Profile Picture
    12 on at

    I feel like I am missing some key information here. can you provide a code example of how ClearCollect can be used to define AFTable?

     

    for clarity the table is being pulled from a datasource not created inside of the app itself.

  • Verified answer
    timl Profile Picture
    37,287 Super User 2026 Season 2 on at

    @Grisdale 

    ClearCollect(AfTable,
     YourSourceData
    )
  • Verified answer
    v-jefferni Profile Picture
    Microsoft Employee on at

    Hi @Grisdale ,

     

    You just need to replace Set with ClearCollect in your App for all the Set(AFTable, ...) related formulas. The difference between collections and variables is that variables could only be set or update, in short it's blank value exchanges with a specific value (text, record or table, no restriction), but you cannot modify a variable by adding/removing an item to/in it. While a Collection is a temporary table, you can add a new record to it using Collect, remove a specific record from it using Remove/RemoveIf, update it from beginning using ClearCollect, clear it using Clear, or update a specific record using Patch/Update.

    Understand variables in canvas apps - Power Apps | Microsoft Learn

    Create and update a collection in a canvas app (contains video) - Power Apps | Microsoft Learn

     

    Best regards,

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
11manish Profile Picture

11manish 394 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 328

#3
WarrenBelz Profile Picture

WarrenBelz 324 Most Valuable Professional

Last 30 days Overall leaderboard