A virtual column is a column that doesn't correspond to an actual column in the underlying spreadsheet. Instead, it is automatically computed via an app formula expression. Their values are not actually stored anywhere, so they won't show up in your spreadsheet once you create them. They do, however, impact your app, behaving much like an ordinary column.
Here are three common use cases for virtual columns:
- To combine other columns: in an app that captures a FirstName and a LastName, a virtual column could construct FullName with the app formula,
CONCATENATE([LastName], ", ", [FirstName]). See also: CONCATENATE().
- To construct conditional values: in an app that captures contact information, a virtual column called PreferredPhoneNumber may be defined with the app formula,
IF([UseMobilePhone?], [MobilePhoneNumber], [PhoneNumber]). See also: IF().
- To construct complex Yes/No values: in an app that captures orders, a virtual column named Important? may be defined with the app formula,
OR(([Amount] > 1000.0), ([Quantity] > 100)). See also: OR().
The ability to create complex Yes/No values is really important when they are used in other expressions like column constraints and slice conditions. In short, any time there is a need for a complex condition in an app, it is often worthwhile to create a virtual column to represent the complex condition, then use the virtual column wherever needed.
Adding a Virtual Column
To add a virtual column to a table, in the Data >> Columns tab, click the Add Virtual Column button for the intended table:
You must specify an app formula expression. Typically, the app formula uses values of other columns in the same row.
The virtual column's type will be automatically detected by the app editor.
Ordering of Virtual Columns
Virtual columns occur in the table's column order after all non-virtual columns, in the order they were created. In the app editor, the color of the edit icon preceding a virtual column is different than that for a non-virtual column:
In a form view for a table, all columns, virtual and non-virtual, occur in the order they are listed for the table, as described above. To change the order of columns in a form view, create a slice with the desired column ordering and use the slice's form view instead.
In other view types, you may have the option to set the column order. For instance, in a table view, the column order is controlled by the Column order option:
Removing a Virtual Column
To remove a virtual column, go to the column's configuration screen and click the Delete button:
Note that the app editor will not prevent you from deleting a virtual column in use elsewhere in your app. After saving the change, the app editor may display errors noting references to the now-deleted virtual column. These errors will likely render your app unusable until the they are corrected.
Automatic Virtual Columns
Sometimes, AppSheet will add virtual columns automatically. Typically, these automatic virtual columns are added when a table is first added to the app, or when the table's structure is regenerated. These columns are typically added as a convenience based on common use. You may use, edit, or remove most system-added virtual columns as you see fit.
AppSheet also adds virtual columns to track reverse references. These virtual columns can be recognized by the following properties:
- The column name will begin with "Related", like Related Orders.
- The app formula will use the REF_ROWS() function.
- Column type List and element type Ref.
- Description text like "... entries that reference this entry in the ... column".
While the app editor will allow you to delete these columns, they will be recreated automatically the next time the app configuration is saved; there is no way to delete them permanently. Some reconfiguration of these columns is possible, though.