# Dynamically duplicate x Rows in a table based on criteria

**URL:** https://community.glideapps.com/t/dynamically-duplicate-x-rows-in-a-table-based-on-criteria/62635
**Category:** Ask for Help
**Created:** [June 10, 2023, 7:11pm UTC](https://community.glideapps.com/t/dynamically-duplicate-x-rows-in-a-table-based-on-criteria/62635 "2023-06-10T19:11:47Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Mahim](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/mahim/32/24888_2.png) [@Mahim](https://community.glideapps.com/u/Mahim)
#### Post date: [June 10, 2023, 7:11pm UTC](https://community.glideapps.com/t/dynamically-duplicate-x-rows-in-a-table-based-on-criteria/62635/1 "2023-06-10T19:11:47Z")

</div>

I’m creating a workout app where I’d like to give the coach a 1 click option to duplicate an entire week’s worth of workouts for a specific client. he can then modify the week as needed. The tricky part is that the number of rows to duplicate depends. The backend is connected to Google sheets.

So for example: let’s say a client has 5 rows of workouts for week 1. I want to duplicate values in columns A, B, and C + increment the value in the “Week #” column by 1. The output would be the same 5 rows of workouts with the value in the Week # column all being 2.

There’s no native way to accomplish this in Glide, but I was suggested to use something like Zapier or Make to “make” it happen.

Any insights from the community on this would be much appreciated!

---

<div class="post-metadata">

### Author: ![Tamara\_Didenko](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/tamara_didenko/32/42215_2.png) [@Tamara\_Didenko](https://community.glideapps.com/u/Tamara_Didenko)
#### Post date: [June 10, 2023, 7:58pm UTC](https://community.glideapps.com/t/dynamically-duplicate-x-rows-in-a-table-based-on-criteria/62635/2 "2023-06-10T19:58:39Z")

</div>

Why do you need to duplicate those rows? Is there any other information stored in those rows that would change week-to-week?

If the goal is to simply duplicate the week exactly, you don’t need to duplicate rows, you just need to duplicate relations  
 ![CleanShot 2023-06-10 at 12.52.30](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/b/1/b1dad63c2210d5f8125b4d75370bad5a84c1bfab.gif)

Here I have 2 tables:  
**Workouts** just has your “unique workouts”

 ![CleanShot 2023-06-10 at 12.53.49@2x](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/a/b/ab9d74f2a5dd7a8ab61a5bbbcfc85e984100e90b.png)

And **weeks**

 ![CleanShot 2023-06-10 at 12.54.47@2x](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/8/3/83ba32a4549078a7a350f9469044d9caf889018e.png)  
Which has a list of workouts for that week.

Week numbering can also be automatic, I’m just being lazy here 🤪 But check [this post](https://community.glideapps.com/t/how-do-i-create-an-auto-incrementing-row-number-with-glide-tables/39572)

---

<div class="post-metadata">

### Author: ![Mahim](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/mahim/32/24888_2.png) [@Mahim](https://community.glideapps.com/u/Mahim)
#### Post date: [June 10, 2023, 9:26pm UTC](https://community.glideapps.com/t/dynamically-duplicate-x-rows-in-a-table-based-on-criteria/62635/3 "2023-06-10T21:26:54Z")

</div>

So the repetitions, weight, and or # of sets of a movement may change on a week to week basis. The coach would change these fields after the initial duplication if needed, so I want to give that functionality to him

---

<div class="post-metadata">

### Author: ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)
#### Post date: [June 10, 2023, 11:28pm UTC](https://community.glideapps.com/t/dynamically-duplicate-x-rows-in-a-table-based-on-criteria/62635/4 "2023-06-10T23:28:55Z")

</div>

> [@How do I duplicate an invoice and line items within it?](https://community.glideapps.com/t/how-do-i-duplicate-an-invoice-and-line-items-within-it/62504/2):
>
> I think you have to use a third-party option like Make to get this to work. You would have to create a JSON structure in the Invoices table to represent the invoice columns, and an array of items that are related to that invoice. Send that structure to Make using a webhook action, and then use a parse JSON module. From the resulting JSON, first, use the Glide API to create an Invoice line with the invoice-level info. You will then get the rowID of the invoice. Create an iterator to iterate t…

I think this can be applied here.
