Example representation: Data model with a table and metric

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:

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 metric.

To create this data model in the Sigma UI:

  1. Go to the Home page.

  2. Select Create New > Data model.

    A new data model opens.

  3. From the Add element bar, select Data > Table.

  4. In the Select source modal, search for the table PLUGS_ELECTRONICS_HANDS_ON_LAB_DATA in the EXAMPLES.PLUGS_ELECTRONICS schema.

  5. Select the table to add it to the data model.

    The table appears in the data model.

  6. Select the PLUGS_ELECTRONICS_HANDS_ON_LAB_DATA table.

  7. In the editor panel, select Properties.

  8. In the metrics section, select Add metric.

  9. In the Add a metric modal, enter the following information:

    FieldValue
    NameUnique products
    FormulaCountDistinct([SKU Number])
  10. Select Save.

  11. 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": "977f5eda-6bf3-4a1d-af8a-1c9e94cf8187",
  "name": "metric",
  "url": "https://aws-api.sigmacomputing.com/org-name/data-model/metric-K8qufRfLqtuILIwVQflWBZ",
  "documentVersion": 2,
  "latestDocumentVersion": 2,
  "ownerId": "fOsrWKBxSMe8HqLmT0nXESkGLpkIc",
  "folderId": "fcb10706-125c-4a83-83d1-2977c8d963a0",
  "createdBy": "fOsrWKBxSMe8HqLmT0nXESkGLpkIc",
  "updatedBy": "fOsrWKBxSMe8HqLmT0nXESkGLpkIc",
  "createdAt": "2025-11-21T20:44:20.745Z",
  "updatedAt": "2026-01-22T17:58:31.897Z",
  "schemaVersion": 1,
  "pages": [
    {
      "id": "UQniOMxzUY",
      "name": "Page 1",
      "elements": [
        {
          "id": "xDD395d37e",
          "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": "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]"
            }
          ],
          "metrics": [
            {
              "id": "1ka0apXiVj",
              "formula": "CountDistinct([Sku Number])",
              "name": "Unique Products"
            }
          ],
          "order": [
            "inode-4exq8bsACBpDyQUvKGGTO0/ORDER_NUMBER",
            "inode-4exq8bsACBpDyQUvKGGTO0/DATE",
            "inode-4exq8bsACBpDyQUvKGGTO0/SKU_NUMBER",
            "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 metrics

In the representation above, the metric created in steps 11-12 is represented by an object in the metrics array of the table element:

Metric representation
...
[
  {
    "id": "1ka0apXiVj",
    "formula": "CountDistinct([Sku Number])",
    "name": "Unique Products"
  }
]
...

Here, the id property is the unique identifier of the metric, the formula property defines the metric logic, and the name property defines the name of the metric.