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 / Collection Update n nu...
Power Apps
Answered

Collection Update n number of times

(0) ShareShare
ReportReport
Posted on by 29

Hi, 

 

I'm trying to build a powerapp that will update a collection from a form with a certain number of records that will be manipulated further later. In my form I currently have two text inputs fields Name, and Count. 

 

What I want my end result to be, if I enter 'Apple' as Name and '4' as Count, I want to have four records created in the collection with 'Apple' in the 'Name' field. Next, if I enter 'Blueberry' as Name and '10' as Count, I want to have ten records created in the collection with 'Blueberry' in the name. This would be 14 records in total. 

 

Any ideas how to accomplish?

Categories:
  • RusselThomas Profile Picture
    4,014 on at

    Hi @kevinsa ,

    Couple of ways you can achieve this - this is how I would do it - add a button and set it's OnSelect: property to

    ForAll(Sequence(Value(countInput.Text)), Collect(collectMyCollection, {Name: NameInput.Text}))

    This will continue to append to the collection each time you press the button until you use Clear() or ClearCollect().

    Note: you can only use Clear() and ClearCollect() outside the ForAll().

    Hope this helps,

    RT

  • kevinsa Profile Picture
    29 on at

    HI @RusselThomas ,

     

    Sorry for taking so long to reply - lots of other stuff on the go. Appreciate your reply - I think I may not have clearly expressed where the input data is coming from. I'll give greater insight - 

     

    I will have two collections. The first __planning, and the second __confirmed

     

    In __planning, I am using a two text input fields to append the collection, one is 'fruit' and a second 'count'.  In __planning I use it as a temporary storage location as the user may want to make changes as we go. I don't want the user to be populating the __confirmed collection until all they input all their starting data in __planning. The end result is the collection for __planning like below:

     

    fruitcount
    Apple4
    Blueberry

    10

     

    I have a second screen that would display the entire __planning collection allowing the user to review and make any last minute changes. Once the user is satisfied and click a button, I want a new collection to be created based off of data from the __planning collection - not from other control inputs. The end result for the __confirmed collection would look like this:

    fruit
    Apple
    Apple
    Apple
    Apple
    Blueberry
    Blueberry
    Blueberry
    Blueberry
    Blueberry
    Blueberry
    Blueberry
    Blueberry
    Blueberry
    Blueberry
  • Verified answer
    RusselThomas Profile Picture
    4,014 on at

    Hi @kevinsa ,

    Thanks for clarifying - can I assume then that you have the __planning table part sorted out and you just want to create the __confirmed collection from the __planning collection?

    If so, then you can just wrap the above formula in a ForAll() for the planning table as input;

    ForAll(__planning,
     ForAll(Sequence(ThisRecord.count), Collect(__confirmed, {fruit: ThisRecord.fruit}))
    )

     

     Let me know if that helps,

     

    Kind regards,

    RT

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 381 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 340

#3
WarrenBelz Profile Picture

WarrenBelz 187 Most Valuable Professional

Last 30 days Overall leaderboard