Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

Add multiple rows to gallery based on column value

(0) ShareShare
ReportReport
Posted on by 227

Hi,

 

I have an editable grid that patches to a SharePoint list. As of right now, the add row button adds in 1 row at a time with some of the values already preset when the row is added. I have a column named "EventDays" in the parent sharepoint list and need the add row button to add x amount of rows based on the "EventDays" value. "EventDays" is a calculated column in the sharepoint list. So if the "EventDays" = 5 rows, the add row button should add 5 rows at once. I still want the ability for the rows to have the preset values there. Any help is appreciated!

 

here is my screen:

NPatel12498_0-1702409796520.png

 

Add Row On Select:

Patch(
 'Checklist Details',
 Defaults('Checklist Details'),
 {Title: Last('Event Information').ID},
 {'Event Date': Last('Event Information'). 'Event Start Date'},
 {'Event Zip': Last('Event Information'). 'Event Zip Code'},
 {'NNAttendees': Last('Event Information'). 'NN Attendees'},
 {'N Attendees': Last('Event Information').'N Attendees'}
);
Set(varReset,false);
Set(varReset,true);

ClearCollect(colPerDiemRate,Table1);

 

Gallery Items:

Sort(
 Filter(
 'Checklist Details',
 varReset),
 Modified,
 SortOrder.Descending)

 

Save On Select:

Patch(
 'Checklist Details',
 ShowColumns(
 colMealUpdates,
 "Title",
 "Event_x0020_Date",
 "Event_x0020_Duration_x0020__x002",
 "N_x002d_N_x0020_Attendees",
 "N_x0020_Attendees",
 "Per_x0020_Diem_x0020_Rate",
 "Per_x0020_Diem_x0020_Total",
 "Required_x0020_Meals",
 "ID",
 "Total_x0020_Attendees",
 "Event_x0020_Zip"
 )
);
Notify(
 "Meal details have been updated successfully",
 NotificationType.Success,
 3000
);
Clear(colMealUpdates);
Set(varReset,false);
Set(varReset,true);
Navigate(TrackingScreen)

 

  • NP-18101421-0 Profile Picture
    227 on at
    Re: Add multiple rows to gallery based on column value

    Woohoo that worked! Awesome, thank you so much. Appreciate it 🙂 Happy holidays

  • Verified answer
    cwebb365 Profile Picture
    3,294 Most Valuable Professional on at
    Re: Add multiple rows to gallery based on column value

    Lookups work fine in that case, it returns the first entry. I don't understand your schema enough to tell you what to do. You need to somehow find the Event days on a label. Once you do that you can use that Code block inside the sequence to loop through and create that many records. 

     

    Based on some of the code in your original post looks like you're just going off the last Event Information entry using Last. So you could probably use 

    ForAll( Sequence(Value(Last('Event Information').EventDays)), 

     

  • NP-18101421-0 Profile Picture
    227 on at
    Re: Add multiple rows to gallery based on column value

    The look up function wont work because the parent list has a one to many relationship with the list in the gallery... so that is why it keeps throwing an error.

  • cwebb365 Profile Picture
    3,294 Most Valuable Professional on at
    Re: Add multiple rows to gallery based on column value

    Your Lookup() is all over the place, need to put a label out and put in the lookup to get your eventdays properly. Once you have that take and replace the lookup inside the Value(). 

     

    You could also replace the Value() with a 5 and test it make sure it works how you want, then figure plug in the Value(Lookup()) that pulls the Eventdays in.

  • NP-18101421-0 Profile Picture
    227 on at
    Re: Add multiple rows to gallery based on column value

    Getting the following error:

    NPatel12498_1-1702415416086.png

     

     

  • cwebb365 Profile Picture
    3,294 Most Valuable Professional on at
    Re: Add multiple rows to gallery based on column value

    I can't remember if PowerApps can use calculated column for the value. If you can then you could just wrap your existing Patch in a ForAll

     

    ForAll ( Sequence( Value(Lookup(Parent Sharepoint list, ID = however you get the row from this list).EventDays)), 

     

    Patch Logic 

     

    )

     

    This will run it 5 times. If Event Days is 5. 

     

    This assumes the 5 rows use the same data. If it's different data then Will need a different approach. 

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,660 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,004 Most Valuable Professional

Leaderboard