Auto Increment

in Tables can we create a column like ID and it should be auto increment like 1 ,2 ,3 ....

same as Identity in SQL

Also once table is created , we can not rearrange the columns in the table , let say i have created A , B, C ,
now i want it like A , C, B , Do i need to delete and create one more time

1 Like

Hi @Anil-470f,

You can insert an auto-increment number in a column through an Automation. For example, you can write an automation that will be triggered when a Row is added, and set the Id to the MAX of the value in the Id column + 1.

Having said this, normally, you do not need to keep a unique Id, because the Rowlink of a row is unique. This is typically how you can do 1:1 or 1:Many relationships between tables. You can format the column as a Rowlink and select the row - and this is the way you create a relationship between two tables. The cell is displayed in blue.

As for rearranging the columns, you can easily grab the three dotted handle above in the column header and move it.

Grab Column

Move Column

This returing always one when new row is added

This is behaving Different ,when i try to add the data from screen, i was trying to give ID as 4 , then is 4 +1 =5 this is adding updating 5 to ID column

i think , since i have used number as column Type and default value is
0, then 0+1=1 so this is returning 1

Hi @Anil-470f,

Few important things for your consideration:

#1. There is a difference between:

=MAX([ID]) + 1


= MAX(A_Tasks[ID]) + 1

When you refer to the column by itself ([ID), you are referring to the value within the cell in the current row. So MAX of the value in the current row is likely to be 0 if it the cell is empty. When you refer to TableName[ID], you are referring to the entire column - so MAX(TableName[ID]) returns the maximum value in the entire column labeled Id.

#2. You should not set the value from the screen for the Id column if you intend to use the Automation to set the value. Combined with #1 above, what is happening is the automation is taking the value you entered in the cell of the same row - based on MAX([ID]) - which returns 4 (the value you set) and adding 1 to it. Best to let the automation do its job by adding 1 to the maximum value.

#3. If there are no rows in the table, you may need to seed the value. You can do this by using IFERROR to check whether MAX([ID]) returns an error, and setting the value to 0.

Hope this helps.


@Anil-470f Just a tip, but in Honeycode it's not normally necessary to create arbitrary uids for each record. When I started building I used to do the same thing in all my projects, just out of habit. But rowlinks are really powerful, and let you get away without the need for it. Just something to think on. :slight_smile:

1 Like