Model Query
The Model Query activity executes a structured query against the Una model and writes the results either to a staging table, to a workflow context variable, or both.
Purpose
Use the Model Query activity to:
- Extract data from the Una model into a staging table for downstream processing (reporting, exports, ETL)
- Read a summary value from the model into a context variable for use in conditions or messages
- Build data pipelines that pull model data and push it to external systems
Configuration
Query
The model query definition. Click the edit button to open the query builder, which lets you define:
- The axes (rows, columns) and which dimensions to include on each
- The measure(s) to retrieve
- Member filters and selections per dimension
The query is stored as a structured JSON object. Use the query builder in the activity editor to define the axes, measures, and member filters.
The entire query JSON is interpolated at runtime — you can embed {{var:Period}} references inside the query definition for dynamic member selections.
Staging Table
The name of a staging table to write results into. Each result row becomes a row in the table with columns:
- For each axis dimension:
<Dimension>_Key,<Dimension>_Name,<Dimension>_Caption Data— the numeric value for that cell
Leave blank if you only need the result in the context variable.
Result Context Key
The workflow context variable name where the full query result is stored as a JSON string.
Default key: ModelQueryWorkflowActivity_ResponseContextKey
Rename it to something meaningful (e.g. RevenueQueryResult). Leave blank if you only need the staging table output.
At least one of Staging Table or Result Context Key must be provided.
Behavior
- The query JSON is serialized and interpolated against the current workflow context.
- The model query runner executes the query.
- If Result Context Key is set, the raw result is serialized to JSON and stored in the context.
- If Staging Table is set, the result is flattened into rows and bulk-inserted into the staging table.
Output Schema (Staging Table)
For a query with two dimensions (e.g. Entity and Account) the staging table will have:
| Column | Description |
|---|---|
Entity_Key | Member key for the Entity dimension |
Entity_Name | Member name |
Entity_Caption | Member caption |
Account_Key | Member key for the Account dimension |
Account_Name | Member name |
Account_Caption | Member caption |
Data | Numeric data value |
Usage Patterns
Query Into Staging, Then Export
Model Query ──> Save File (generate CSV from staging)
└── Staging Table: QueryResults
Query: {Entity × Account, Measure: Actual}
Read a Summary Value Into Context
Model Query ──> If ({{var:TotalRevenue}} > 1000000)
└── Result Key: TotalRevenue
Query: {Total Entity, Measure: Revenue}
Usage Notes
- The staging table is created or replaced each time the activity runs. Existing rows are not preserved.
- The
Datacolumn is of typedouble. Null cells from the model are written as0or omitted depending on the query configuration. - If the query returns a large result set, writing to a staging table is significantly more efficient than storing the full JSON in a context variable.
Best Practices
- Rename the Result Context Key if using it — the default name is long and will be ambiguous if you have multiple Model Query activities in the same workflow.
- Use the staging table output when the result will be consumed by another data activity (ETL, SQL Bulk Copy, Save File). Use the context key only for scalar values or small result sets you need to branch on.
- Use interpolation in the query JSON to pass dynamic period or entity selections rather than hardcoding members.
JSON Reference
{
"discriminator": "ModelQueryWorkflowActivity",
"activityId": "<uuid>",
"name": "Model Query",
"positionX": 0,
"positionY": 0,
"advanceRule": 2,
"stagingTable": "QueryResults",
"query": { },
"responseContextKey": "RevenueQueryResult"
}
| Property | Type | Description |
|---|---|---|
stagingTable | string | null | Corresponds to the Staging Table field. The name of the staging table to write query results into. Leave null to skip staging table output. |
query | object | null | Corresponds to the Query field. The structured model query definition object (built via the query builder). The entire object is interpolated at runtime. |
responseContextKey | string | Corresponds to the Result Context Key field. Workflow context key where the full query result is stored as a JSON string. Defaults to ModelQueryWorkflowActivity_ResponseContextKey. |