Example representation: Data model with a table and a calculated column
This is an example representation of a data model, created using the get a data model representation endpoint. Representations like this one can be used to create a data model from code using the create a data model from a representation endpoint. Each page in this example library includes the code representation of the data model and step-by-step instructions to create it in the Sigma UI.
Consult this example and others in the Data model representation example library to:
- Troubleshoot the formatting of a particular feature in code representation
- Relate a feature from the Sigma UI to its representation in code
- Provide context to AI tools used to create data models from code
This example representation cannot be used as-is. All identifying details, such as IDs, names, and URLs, have been replaced with randomized ID values or generic substitutions. The format of these contents, like the length of ID values, is preserved for demonstrative purposes. However, this representation cannot be directly used without modification to the base URL, connection details, and more. For more information, see Create and manage data models from code.
System and user requirements
To complete the steps in this example, you must meet the user requirements listed below for creating the data model in the UI and creating it from code.
The ability to create this data model in the Sigma UI requires the following:
- You must be assigned an account type with the Create, edit, and publish data models permissions enabled.
- You must have access to a connection to a data platform.
The ability to create a data model from code requires the following:
- You must be assigned the Admin account type.
- You must have developer credentials for the Sigma API. For more information, see Get started with the Sigma REST API.
This example uses a table from the Sigma Sample Connection. Your organization might have disabled access to the Sigma sample connection. If so, you can contact an admin to enable it, or use a table from another connection to follow along with this example.
Create the example data model in the Sigma UI
This example shows a simple data model with a single table element, sourced from a warehouse table, with a calculated column.
To create this data model in the Sigma UI:
-
Go to the Home page.
-
Select
Create New > Data model.
A new data model opens.
-
From the Add element bar, select Data > Table.
-
In the Select source modal, search for the table
PLUGS_ELECTRONICS_HANDS_ON_LAB_DATAin theEXAMPLES.PLUGS_ELECTRONICSschema. -
Select the table to add it to the data model.
The table appears in the data model.
-
Select the table element.
-
Select the caret (
) in the workbook header to open the document menu, then select File > Rename.
-
Rename the data model as
calculated-column. -
Click the caret (
) in the column header for the Sku Number column, and select Add new column.
-
Rename the column to
Profit. -
In the formula bar, enter the formula
[Price] - [Cost]. -
Press Enter or click the checkmark to save the formula.
The calculated column
Profitappears in the table. -
Repeat steps 9-12 to add columns with the following names and formulas:
Name Formula CA Camera ProfitIf([Product Family] = "Camera Accessories" and [Store State] = "California", [Profit], 0)Cust Loyalty TierCoalesce(Text([Cust Json].LOYALTY_EXTRA.LOYALTY_TIER), "none")Cust Lifetime DaysDateDiff("day", Date([Cust Json].CUST_SINCE), Today()) -
Select Publish.
Get a JSON representation of this data model
To get a JSON representation of this data model, follow the steps in Get the code representation of a data model.
The JSON representation of this data model appears like the following:
JSON representation
{
"dataModelId": "67872f3f-f0e3-4367-b761-c2ba3e70ac8c",
"name": "calculated-column",
"url": "https://aws-api.sigmacomputing.com/org-name/data-model/calculated-column-4ywLxWpBiMvSQyyI1a3Bh2",
"documentVersion": 3,
"latestDocumentVersion": 3,
"ownerId": "fOsrWKBxSMe8HqLmT0nXESkGLpkIc",
"folderId": "fcb10706-125c-4a83-83d1-2977c8d963a0",
"createdBy": "fOsrWKBxSMe8HqLmT0nXESkGLpkIc",
"updatedBy": "fOsrWKBxSMe8HqLmT0nXESkGLpkIc",
"createdAt": "2025-11-21T20:17:12.979Z",
"updatedAt": "2026-03-25T15:07:38.807Z",
"schemaVersion": 1,
"pages": [
{
"id": "WmAQVNOYy0",
"name": "Page 1",
"elements": [
{
"id": "MzTN7o6K37",
"kind": "table",
"source": {
"connectionId": "9ad28df9-5f5f-4bae-8985-bb12d25829de",
"kind": "warehouse-table",
"path": [
"EXAMPLES",
"PLUGS_ELECTRONICS",
"PLUGS_ELECTRONICS_HANDS_ON_LAB_DATA"
]
},
"columns": [
{
"id": "inode-4exq8bsACBpDyQUvKGGTO0/ORDER_NUMBER",
"formula": "[PLUGS_ELECTRONICS_HANDS_ON_LAB_DATA/Order Number]"
},
{
"id": "inode-4exq8bsACBpDyQUvKGGTO0/DATE",
"formula": "[PLUGS_ELECTRONICS_HANDS_ON_LAB_DATA/Date]"
},
{
"id": "inode-4exq8bsACBpDyQUvKGGTO0/SKU_NUMBER",
"formula": "[PLUGS_ELECTRONICS_HANDS_ON_LAB_DATA/Sku Number]"
},
{
"id": "xPgl3hslcx",
"formula": "DateDiff(\"day\", Date([Cust Json].CUST_SINCE), Today())",
"name": "Cust Lifetime Days"
},
{
"id": "bIXEgcxDbg",
"formula": "Coalesce(Text([Cust Json].LOYALTY_EXTRA.LOYALTY_TIER), \"none\")",
"name": "Cust Loyalty Tier"
},
{
"id": "gRIAjWxeYz",
"formula": "If([Product Family] = \"Camera Accessories\" and [Store State] = \"California\", [Profit], 0)",
"name": "CA Camera Profit"
},
{
"id": "mnyEC6FZYT",
"formula": "[Price] - [Cost]",
"name": "Profit"
},
{
"id": "inode-4exq8bsACBpDyQUvKGGTO0/QUANTITY",
"formula": "[PLUGS_ELECTRONICS_HANDS_ON_LAB_DATA/Quantity]"
},
{
"id": "inode-4exq8bsACBpDyQUvKGGTO0/COST",
"formula": "[PLUGS_ELECTRONICS_HANDS_ON_LAB_DATA/Cost]"
},
{
"id": "inode-4exq8bsACBpDyQUvKGGTO0/PRICE",
"formula": "[PLUGS_ELECTRONICS_HANDS_ON_LAB_DATA/Price]"
},
{
"id": "inode-4exq8bsACBpDyQUvKGGTO0/PRODUCT_TYPE",
"formula": "[PLUGS_ELECTRONICS_HANDS_ON_LAB_DATA/Product Type]"
},
{
"id": "inode-4exq8bsACBpDyQUvKGGTO0/PRODUCT_FAMILY",
"formula": "[PLUGS_ELECTRONICS_HANDS_ON_LAB_DATA/Product Family]"
},
{
"id": "inode-4exq8bsACBpDyQUvKGGTO0/PRODUCT_LINE",
"formula": "[PLUGS_ELECTRONICS_HANDS_ON_LAB_DATA/Product Line]"
},
{
"id": "inode-4exq8bsACBpDyQUvKGGTO0/BRAND",
"formula": "[PLUGS_ELECTRONICS_HANDS_ON_LAB_DATA/Brand]"
},
{
"id": "inode-4exq8bsACBpDyQUvKGGTO0/PRODUCT_NAME",
"formula": "[PLUGS_ELECTRONICS_HANDS_ON_LAB_DATA/Product Name]"
},
{
"id": "inode-4exq8bsACBpDyQUvKGGTO0/STORE_NAME",
"formula": "[PLUGS_ELECTRONICS_HANDS_ON_LAB_DATA/Store Name]"
},
{
"id": "inode-4exq8bsACBpDyQUvKGGTO0/STORE_KEY",
"formula": "[PLUGS_ELECTRONICS_HANDS_ON_LAB_DATA/Store Key]"
},
{
"id": "inode-4exq8bsACBpDyQUvKGGTO0/STORE_REGION",
"formula": "[PLUGS_ELECTRONICS_HANDS_ON_LAB_DATA/Store Region]"
},
{
"id": "inode-4exq8bsACBpDyQUvKGGTO0/STORE_STATE",
"formula": "[PLUGS_ELECTRONICS_HANDS_ON_LAB_DATA/Store State]"
},
{
"id": "inode-4exq8bsACBpDyQUvKGGTO0/STORE_CITY",
"formula": "[PLUGS_ELECTRONICS_HANDS_ON_LAB_DATA/Store City]"
},
{
"id": "inode-4exq8bsACBpDyQUvKGGTO0/STORE_ZIP_CODE",
"formula": "[PLUGS_ELECTRONICS_HANDS_ON_LAB_DATA/Store Zip Code]"
},
{
"id": "inode-4exq8bsACBpDyQUvKGGTO0/STORE_LATITUDE",
"formula": "[PLUGS_ELECTRONICS_HANDS_ON_LAB_DATA/Store Latitude]"
},
{
"id": "inode-4exq8bsACBpDyQUvKGGTO0/STORE_LONGITUDE",
"formula": "[PLUGS_ELECTRONICS_HANDS_ON_LAB_DATA/Store Longitude]"
},
{
"id": "inode-4exq8bsACBpDyQUvKGGTO0/CUST_KEY",
"formula": "[PLUGS_ELECTRONICS_HANDS_ON_LAB_DATA/Cust Key]"
},
{
"id": "inode-4exq8bsACBpDyQUvKGGTO0/CUSTOMER_NAME",
"formula": "[PLUGS_ELECTRONICS_HANDS_ON_LAB_DATA/Customer Name]"
},
{
"id": "inode-4exq8bsACBpDyQUvKGGTO0/CUST_JSON",
"formula": "[PLUGS_ELECTRONICS_HANDS_ON_LAB_DATA/Cust Json]"
}
],
"order": [
"inode-4exq8bsACBpDyQUvKGGTO0/ORDER_NUMBER",
"inode-4exq8bsACBpDyQUvKGGTO0/DATE",
"inode-4exq8bsACBpDyQUvKGGTO0/SKU_NUMBER",
"xPgl3hslcx",
"bIXEgcxDbg",
"gRIAjWxeYz",
"mnyEC6FZYT",
"inode-4exq8bsACBpDyQUvKGGTO0/QUANTITY",
"inode-4exq8bsACBpDyQUvKGGTO0/COST",
"inode-4exq8bsACBpDyQUvKGGTO0/PRICE",
"inode-4exq8bsACBpDyQUvKGGTO0/PRODUCT_TYPE",
"inode-4exq8bsACBpDyQUvKGGTO0/PRODUCT_FAMILY",
"inode-4exq8bsACBpDyQUvKGGTO0/PRODUCT_LINE",
"inode-4exq8bsACBpDyQUvKGGTO0/BRAND",
"inode-4exq8bsACBpDyQUvKGGTO0/PRODUCT_NAME",
"inode-4exq8bsACBpDyQUvKGGTO0/STORE_NAME",
"inode-4exq8bsACBpDyQUvKGGTO0/STORE_KEY",
"inode-4exq8bsACBpDyQUvKGGTO0/STORE_REGION",
"inode-4exq8bsACBpDyQUvKGGTO0/STORE_STATE",
"inode-4exq8bsACBpDyQUvKGGTO0/STORE_CITY",
"inode-4exq8bsACBpDyQUvKGGTO0/STORE_ZIP_CODE",
"inode-4exq8bsACBpDyQUvKGGTO0/STORE_LATITUDE",
"inode-4exq8bsACBpDyQUvKGGTO0/STORE_LONGITUDE",
"inode-4exq8bsACBpDyQUvKGGTO0/CUST_KEY",
"inode-4exq8bsACBpDyQUvKGGTO0/CUSTOMER_NAME",
"inode-4exq8bsACBpDyQUvKGGTO0/CUST_JSON"
]
}
]
}
]
}Representing calculated columns
In this representation, the calculated columns are represented by these objects in the columns array of the table element:
Calculated column representation
...
[
{
"id": "xPgl3hslcx",
"formula": "DateDiff(\"day\", Date([Cust Json].CUST_SINCE), Today())",
"name": "Cust Lifetime Days"
},
{
"id": "bIXEgcxDbg",
"formula": "Coalesce(Text([Cust Json].LOYALTY_EXTRA.LOYALTY_TIER), \"none\")",
"name": "Cust Loyalty Tier"
},
{
"id": "gRIAjWxeYz",
"formula": "If([Product Family] = \"Camera Accessories\" and [Store State] = \"California\", [Profit], 0)",
"name": "CA Camera Profit"
},
{
"id": "mnyEC6FZYT",
"formula": "[Price] - [Cost]",
"name": "Profit"
}
]
...Here, the formula and name of the calculated column are defined in an object in the columns array, listed alongside the other columns in the table.
Columns sourced directly from warehouse tables use a reference in the format [table name/column name], while calculated columns show the formula used to define the column, as shown above.
Updated about 7 hours ago