AppSheet formulas in Emberblocks: what translates, and what does not yet
How the Emberblocks importer rewrites AppSheet expressions: IFS, SWITCH, ISNOTBLANK, ANY(SELECT()), REF_ROWS and more, plus the ones it reports instead.
Published 9 min read
On this page
The first question AppSheet builders ask before switching is not about tables or views. It is: what happens to my formulas? An AppSheet app keeps most of its logic in expressions: Show_If and Required_If on columns, Valid_If rules, initial values, App formulas, virtual columns, slice filters and action conditions. If those do not come across, the app does not come across.
This article lists, rule by rule, what the Emberblocks AppSheet importer does with each kind of expression today. It is written from the importer's own translation rules, not from a plan, and every example below is the importer's real output. Where something does not translate yet, it says so, gives the code the import report shows, and suggests what to build instead. If you are still deciding whether to move, the AppSheet migration guide covers the whole switch, and the import guide in the docs walks through the upload.
How does the importer treat a formula?
You upload the app's documentation export from the AppSheet editor. The importer reads every table, column, slice, view, action and format rule from it, and sends each expression through a translator that rewrites AppSheet syntax into the Emberblocks expression language. The translated formula is then parsed and type checked against your new app, exactly as if you had typed it into the builder.
The translator is fail-closed. An expression is either translated completely or not at all. If any part of it uses something Emberblocks cannot express, the whole expression is set aside: nothing is ever half-translated into a formula that looks right and quietly does something else. The importer leaves that setting off (a column with no Show_If, a field with no default, a slice that is not created), and the import report lists the item with a code and the original AppSheet formula, so you can rebuild it by hand.
The translation table
The examples use a small order-tracking app: an Orders table that references Customers, a Lines child table, a Products table and a Users table keyed by email with a Role column. Column and table names keep their AppSheet labels.
| AppSheet | Emberblocks | Note |
|---|---|---|
"Open", 42, TRUE | "Open", 42, TRUE | Text, number and yes/no literals carry over as they are. |
[Qty] * [Price] | ([Qty] * [Price]) | The operators & + - * / and the comparisons keep their meaning. Parentheses are added so precedence never shifts. |
[Due] < TODAY() | ([Due] < TODAY()) | Comparisons such as =, <>, < and >= work on every scalar column. |
IF(c, a, b), AND(...), OR(...), NOT(x) | The same functions | IF needs all three arguments, as in AppSheet. |
IFS([Qty] > 100, "Bulk", [Qty] > 10, "Medium") | IF(([Qty] > 100), "Bulk", IF(([Qty] > 10), "Medium", "")) | Becomes nested IFs. When no condition matches the result is empty text, the same blank AppSheet returns. |
SWITCH([Status], "Open", 1, "Done", 2, 0) | IF(([Status] = "Open"), 1, IF(([Status] = "Done"), 2, 0)) | Becomes nested IFs ending in your default. SWITCH needs that default, as in AppSheet. |
[Customer].[Region].[Name] | [Customer].[Region].[Name] | Dereferences carry over up to two hops. |
[_THISROW].[Status] = "Open" | ([Status] = "Open") | Outside a SELECT the current row is implied. Inside one it becomes THISROW[Status]. |
[_THIS] in a column rule | That column | Replaced by the column the rule belongs to. |
[Assigned To] = USEREMAIL() | ([Assigned To].[Email] = USEREMAIL()) | AppSheet compares a Ref by its key value; Emberblocks hops to the key column so the comparison still means the same thing. |
ISBLANK([Due]) | ISBLANK([Due]) | Same function. |
ISNOTBLANK([Due]) | NOT(ISBLANK([Due])) | Emberblocks has no ISNOTBLANK, so it is spelled out. |
ISBLANK([Related Lines]) | (COUNT([Lines]) = 0) | On a related list it means "has no related rows". ISNOTBLANK becomes > 0. |
CONTAINS([Notes], "urgent"), CONCATENATE(...), ENCODEURL(...) | The same functions | Arguments are translated one by one. |
TEXT([Due], "dd/mm/yyyy") | TEXT([Due], "DD/MM/YYYY") | Excel-style date and time masks are rewritten into Emberblocks tokens. TEXT with no mask carries over as it is. |
TODAY(), NOW(), USEREMAIL(), USERROLE() | The same functions | They take no arguments in either language. |
USERNAME() | LOOKUP(USEREMAIL(), [Users].[Email], [Users].[Name]) | Translates when the app has a users table with a Name column. |
IN([Status], LIST("Open", "Late")) | IN([Status], "Open", "Late") | Only the literal LIST form. IN over a column list is in the next section. |
ANY(My Profile[Role]) = "Admin" | (USERROLE() = "Admin") | The My Profile idiom: a slice of the users table filtered to USEREMAIL(). Its Role column becomes the signed-in user's role. |
ANY(My Profile[Team]) | LOOKUP(USEREMAIL(), [Users].[Email], [Users].[Team]) | Any other column of that slice becomes a lookup on the users table. |
ANY(SELECT(Products[Price], [SKU] = [_THISROW].[SKU])) | LOOKUP([SKU], [Products].[SKU], [Products].[Price]) | Translates when the condition is one [Column] = value equality. |
COUNT([Related Lines]) | COUNT([Lines]) | A REF_ROWS virtual column counts the child rows that point at this one. |
SUM([Related Lines][Amount]) | SUM([Lines], [Amount]) | Sums one column of the related rows. |
COUNT(SELECT(Lines[ID], AND([Order] = [_THISROW].[ID], [Shipped] = FALSE))) | COUNT([Lines], ([Shipped] = FALSE)) | The link clause back to the current row is recognised and dropped; the rest stays as the filter. SUM works the same way. |
REF_ROWS("Lines", "Order") | REFROWS([Lines]) | Only as a virtual column, where it becomes a formula field listing the related rows. |
The translated formula still has to pass Emberblocks' own checks before it is kept. A Show_If must produce yes or no, and a default or App formula must produce a value the field can hold. A formula that translates but fails those checks is reported too, with the codes EXPR_CHECK, EXPR_NOT_BOOLEAN or EXPR_KIND.
Not translated yet, and what to do instead
Each of these is reported with its code and the original formula. The setting it belonged to is left off, so the rest of the app still imports and opens.
- UNIQUEID() (
EXPR_UNIQUEID). Emberblocks gives every row its own id, so there is nothing to generate. When UNIQUEID() is a column's initial value the importer drops that default and notes it in the report; reference the row itself instead of a copied id. - USERNAME() with no users table name (
EXPR_USERNAME). It only translates when the app has a users table keyed by email that also has a Name column. Add one, or useUSEREMAIL(). - INPUT() (
EXPR_INPUT). Action input parameters have no equivalent. Collect the value in a form field instead, and let the action or workflow read it from the row. - CONTEXT() (
EXPR_CONTEXT). Emberblocks formulas do not know which view or device they run in. Put the logic on the view itself: give each view its own blocks, or use the view's visibility rule. - [_THISROW_BEFORE], [_THISROW_AFTER] and [_ROWNUMBER] (
EXPR_BOT_CONTEXT). These only exist inside AppSheet bots. Rebuild the bot as an Emberblocks workflow and set its trigger and conditions there. - More than two reference hops (
EXPR_HOP_DEPTH), such as[Customer].[Region].[Manager].[Name]. Add a formula field one table along that already holds the value, then hop to that. - [_THISROW].[Ref].[Col] inside a SELECT() (
EXPR_THISROW_HOP) and a bare [_THISROW] (EXPR_THISROW_BARE). Inside a SELECT only one column of the outer row can be read. Compare on that column, or bring the value onto the row with a formula field first. - An aggregate inside an aggregate's condition (
EXPR_NESTED_AGG), for example a lookup or count inside a COUNT(SELECT()) filter. Split it: put the inner result in its own formula field, then filter on that field. - COUNT or SUM over a whole table (
EXPR_AGG_TARGET) or over a SELECT() with no[fk] = [_THISROW].[key]clause (EXPR_AGG_LINK). Emberblocks aggregates are relative to the current row's related rows. For a whole-table total, use a stat or chart block. - ANY(SELECT()) with more than one condition (
EXPR_ANY_SELECT) and ANY() over a whole column (EXPR_ANY_LIST,EXPR_ANY). Rewrite it as a single-key lookup, or add a key column that makes one equality enough. - IN() over a column list (
EXPR_IN_LIST), such asIN([Status], Orders[Status]). Only the literalIN(x, LIST(a, b))form translates. A reference field already limits choices to rows of another table. - Whole-column lists, LIST() on its own, EnumList and List columns (
EXPR_LIST_VALUE,EXPR_LIST_COLUMN). A list has no single value to compare. Use a multi-reference field or a related list, and test it with COUNT. - Show columns (
EXPR_SHOW_COLUMN). They hold no data. Use a text block or a field group on the record view. - TEXT() masks with no equivalent (
EXPR_TEXT_MASK). Rewrite the mask with plain date tokens such asDD/MM/YYYY. - REF_ROWS() anywhere but a virtual column (
EXPR_REFROWS_SCOPE). Related rows are a formula field in Emberblocks, so REF_ROWS only translates as one. - Any other function (
EXPR_UNSUPPORTED_FN, with the function name), for example AppSheet's ownLOOKUP(),EOMONTH()orMAXROW(). The Emberblocks language is smaller than AppSheet's. Check the expressions guide for the nearest function, or ask Ember to rewrite it. - A rule that reaches too far for where it lives (
EXPR_ROW_SCOPE,EXPR_USER_SCOPE). See the next section.
Where formulas can live
AppSheet lets almost any expression go almost anywhere. Emberblocks is stricter about what a formula may read, depending on the setting it sits in, because some settings run on every keystroke or before the row exists. The importer checks the translated formula against the setting it is headed for. There are four places, from the most limited to the most open:
- Row rules: a field's default value, Required_If, Valid_If and App formula, plus format rule conditions. These may only read the row's own columns. No hops through references, no lookups and no counts. A rule that needs
[Customer].[Region]fails withEXPR_ROW_SCOPE; add a formula field that holds the value and read that. - Who can see a view: a view's Show_If. It may only test the signed-in user, with
USERROLE(),USEREMAIL()and literals. A rule that reads a column fails withEXPR_USER_SCOPE. This is why the My Profile idiom matters:ANY(My Profile[Role]) = "Admin"becomesUSERROLE() = "Admin", which is allowed here. - Everything else: a column's Show_If, an action's condition and a slice filter (which becomes a filtered table). These may hop through references and use LOOKUP, COUNT and SUM.
- Formula fields: an AppSheet virtual column becomes a formula field, which can use everything above plus
REFROWS()for related rows.
A slice filter that tests USEREMAIL() imports as a filtered table and is flagged in the report as a candidate for a role row filter. That is often the better home for it: a row filter applies everywhere the table is read, not only in the views that use the slice. The row and field level permissions article explains the difference.
How to check an import before you rely on it
- Import the app and open the Import report strip under the builder's top bar. Every item that did not import links to the field, view or action it concerns.
- For each skipped expression, read the code and the original formula, then rebuild it using the suggestions above. Most fixes are a formula field or a simpler lookup.
- Preview the app as each role, and check the views and fields that had Show_If rules. A rule that was set aside means the item is shown, not hidden.
- Check the formula fields that came from virtual columns against a few rows you know the answer for.
- Only then point real users at it. Your AppSheet app keeps running in the meantime; the importer reads an export file and never touches the original.
Questions people ask
- Does the importer change my AppSheet app?
- No. It reads the documentation export you download from the AppSheet editor. The original app and its data source are never touched.
- What happens to a formula that cannot be translated?
- The whole formula is set aside, never partly translated. The setting it belonged to is left off, and the import report lists it with a code and the original AppSheet formula so you can rebuild it.
- Do virtual columns come across?
- Yes, when their App formula translates. Each becomes a formula field, including REF_ROWS columns, which become a list of related rows.
- Can I ask Ember to fix the formulas the importer skipped?
- Yes. Paste the original formula from the report into Ask Ember in the builder and say which field it belongs to. Check the result the same way you would check your own.
Written by Apostolos Papadopoulos
Apostolos builds Emberblocks, a visual app builder for internal tools on your own data, from Thessaloniki, Greece. Spotted something wrong or out of date? Write to hello@emberblocks.com.