Selecting a Key

Automatic Key Selection

When you add a new table to you application, AppSheet attempts to find a suitable key for the table. 

AppSheet first examines each worksheet column from left to right, looking for a column that contains unique data values. If your worksheet has a good key column, it is a good practice to make it the leftmost worksheet column. If AppSheet finds such a column, it makes that column the key.

Appsheet next examines pairs of worksheet columns from left to right, looking for a pair of columns that contain unique data values. The pair of columns need not be adjacent. If AppSheet finds such a pair of columns, it will combine the columns to create a "Computed key". The computed key will be added as a Virtual field at the end of the table.

If AppSheet cannot find a key column using any of these techniques, it will default to using row number as the key. This isn’t a good key however, because if entries are moved or deleted, or if users add or delete entries simultaneously, the row number for each row will changes and there is no way for AppSheet to uniquely identify the row. The Editor will give a warning if row number is chosen as the key.


Manual Key Selection

You can manually override AppSheet's key selection.

Do this as follows:

  1. Open the application in the Editor.
  2. Go to the Data > Column Structure tab and Show the table schema.
  3. Uncheck the "Key" property for the existing key columns.
  4. Check the "Key" property for one or more columns.
  5. If you  elect to use a System Generated Key, specify either UNIQUEID() or RANDBETWEEN() in the 'INITIAL VALUE" property of the key column. The key value for a record must be assigned once when the record is created and it must remain constant for the life of the record. That is why you must specify the key value in the 'INITIAL VALUE" property and never the "APP FORMULA" property. The 'INITIAL VALUE" property is computed once when the record is created. By contrast, the "APP FORMULA" is recomputed when the record is created or updated.
  6. Save your changes. 
Have more questions? Submit a request


Please sign in to leave a comment.