# 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:** 1\
**Showing post:** 2

<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.

---

_[View the full topic](https://connect.superhuman.com/t/use-button-to-insert-row-below-current-row/3394)._
