# Use button to insert row below current row

**URL:** <https://connect.superhuman.com/t/use-button-to-insert-row-below-current-row/3394>\
**Category:** Ask the Community\
**Created:** [November 13, 2018, 2:17pm UTC](https://connect.superhuman.com/t/use-button-to-insert-row-below-current-row/3394 "2018-11-13T14:17:16Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![William\_Larsten](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/william_larsten/32/6568_2.png) [@William\_Larsten](https://connect.superhuman.com/u/William_Larsten)\
**Post date:** [November 13, 2018, 2:17pm UTC](https://connect.superhuman.com/t/use-button-to-insert-row-below-current-row/3394/1 "2018-11-13T14:17:16Z")

</div>

I’d like to use the new Detail view on a table and be able to easily add a new row below the one being displayed. The workflow me and my collaborators have means “splitting” a row in two or more sometimes, and it’d be great if I could do this with one click! 🙂 Any ideas?

![34](https://global.discourse-cdn.com/coda1/original/2X/b/b2294a5be1e69fd07d483fbd7f2eee62dccdf599.jpeg)

---

<div class="post-metadata">

**Author:** ![Krunal\_Sheth](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/krunal_sheth/32/5936_2.png) [@Krunal\_Sheth](https://connect.superhuman.com/u/Krunal_Sheth)\
**Post date:** [November 13, 2018, 5:17pm UTC](https://connect.superhuman.com/t/use-button-to-insert-row-below-current-row/3394/2 "2018-11-13T17:17:14Z")

</div>

Hi William,

Interesting problem!

Here’s what I put togather!

 ![NextRowNumber](https://global.discourse-cdn.com/coda1/original/2X/9/9fdc7e26ceccd26d1025eca21a19402da019a82c.gif)

**document is [here](https://coda.io/d/Unique-Row-Number-Generator_dKDHuN90BN8/):**

Here’s how it works:

For rows to show up in specific order, you have to apply some `Sort` to it. In the document I’ve linked I am using `Category Number` as a sort column.

Now, if we can generate a `Category Number` that is between `thisRow` and nextRow and assign that number to newly created record, the newly created record will automatically `appear` as a nextRecord. For example, if current row on which button is clicked is #5 and the next Row is #6, if we can assign, #5.5 to newly created row, it will appear in between. that is what the following formula does

`if(Category.Filter([Category Number] > thisRow.[Category Number]).[Category Number].Sort().First(),(Category.Filter([Category Number] > thisRow.[Category Number]).[Category Number].Sort().First() + thisRow.[Category Number])/ 2, thisRow.[Category Number]+ 1)`

if there is a next record, then it takes Category Number from that one + category number from current row and divides it in half (so in earlier example, it will (5+6)/2 = 5.5) - if the row is the very last row, then it adds 1 to CategoryNumber.

Hope this helps - would be happy to answer any questions (and would love to hear if other folks have different ideas)

Thank you,  
Krunal.  
Engineer - Coda.

---

<div class="post-metadata">

**Author:** ![Jean\_Pierre\_Traets](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/jean_pierre_traets/32/16275_2.png) [@Jean\_Pierre\_Traets](https://connect.superhuman.com/u/Jean_Pierre_Traets)\
**Post date:** [November 13, 2018, 5:46pm UTC](https://connect.superhuman.com/t/use-button-to-insert-row-below-current-row/3394/3 "2018-11-13T17:46:54Z")

</div>

Dear Krunal,

Thank you sharing this creative approach 🏆and sharing in detail the steps 🚶‍♂️ your created to deal with this challenge.  
Many users including me will be able to learn a lot and being encouraged to find solutions for challenges that today seem impossible to overcome.

Thats whats Coda about, FUN ‼

---

<div class="post-metadata">

**Author:** ![William\_Larsten](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/william_larsten/32/6568_2.png) [@William\_Larsten](https://connect.superhuman.com/u/William_Larsten)\
**Post date:** [November 14, 2018, 12:35pm UTC](https://connect.superhuman.com/t/use-button-to-insert-row-below-current-row/3394/4 "2018-11-14T12:35:32Z")

</div>

Thanks! It’s a beautiful solution Krunal, worked like a charm! 😃

I like that it’s built to be flexible regardless of how many new rows are created.

---

<div class="post-metadata">

**Author:** ![BODHI\_SCHNEIDER](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/bodhi_schneider/32/18347_2.png) [@BODHI\_SCHNEIDER](https://connect.superhuman.com/u/BODHI_SCHNEIDER)\
**Post date:** [December 17, 2020, 11:54pm UTC](https://connect.superhuman.com/t/use-button-to-insert-row-below-current-row/3394/5 "2020-12-17T23:54:09Z")

</div>

wow @Krunal_Sheth, What a solution!🏆
