web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Add empty records to a...
Power Apps
Unanswered

Add empty records to a collection dynamically based on a variable

(0) ShareShare
ReportReport
Posted on by 44

Context:

I am building a voting form (of sorts) for a recurring annual process at work.  The form needs to capture nominations, but the total allowed nominations per vote will vary from year to year.  I have setup a global variable to indicate what this "total nominations allowed" will be:

 

Problem:

In order to capture nominations I created a collection that feeds into a gallery control which the user can interact with in order to make their selections. 

How can I pre-emptively create the collection and add X empty records based on "total nominations allowed" number above?

 

I'm trying to avoid the solution below as I would need to adjust this piece of code every year depending on that "total nominations allowed" number:
ClearCollect(colNominations,
    {col1: Blank(), col2: Blank(), ... , coln: Blank()},

    {col1: Blank(), col2: Blank(), ... , coln: Blank()},

    ....

    {col1: Blank(), col2: Blank(), ... , coln: Blank()}

)

Categories:
I have the same question (0)
  • Verified answer
    rizkyaditya Profile Picture
    292 on at

    Hello @sigmaNot ,

     

    You can try this to create that collection :

    ForAll(Sequence(yourtotalNominationsAllowed_Variable) As totalNominationsAllowed, Collect(colNominations, {Id: totalNominationsAllowed.Value, yourColumn1: Blank(), yourColumn2: Blank()}))

     

    I hope this helps!

  • AG-20121725-0 Profile Picture
    44 on at

    Exactly what I was looking for!

     

    Was not aware of the Sequence function, but it seems like this is the closest to an index loop that PowerApps offers.

     

    Thanks.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 759 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 310 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 228

Last 30 days Overall leaderboard