Skip to main content

Model Queries

Model queries retrieve data from a model.

Query Concepts

Axes

Each query contains one or more axes and zero or more filters. The most common format has two axes (first axis being columns and second axis being rows) and looks like an Excel pivot table. Each axis can contain one or more dimensions—for instance, you may want to retrieve Periods on columns and a combination of Stages and KPIs on rows.

JanFebMarAprMayJunJul
SALVolume10151114161820
SALAmount20,00035,23521,72028,34033,00037,67240,000
SQLVolume46810111315
SQLAmount8,00012,00016,00020,00022,00026,00030,000

IncludeEmpty

For each axis, you can specify whether to include empty headers or not. In the table above, for instance, if the SAL/Other row has no values associated with it and IncludeEmpty is set to false, it will not be returned as part of the query results.

JoinType

If an axis has more than one dimension, the join type indicates how members from the different dimensions combine to generate the axis metadata.

Join TypeDescription
Crossjoin (Symmetrical)Uses all possible combinations of members from each dimension. For example, if the first dimension has members SAL and SQL and the second dimension has members Volume and Amount, the resulting headers will be: SAL/Volume, SAL/Amount, SQL/Volume, SQL/Amount. This is the default.
Direct (Asymmetrical)Takes the first member from the first dimension with the first member from the second dimension, and so on. In the example above, the resulting headers would be SAL/Volume, SQL/Amount. In a direct join, all dimension queries should return the same number of members.

Filters

Filters (also known as slicers) are similar to an axis, but unlike axis dimensions, data is not broken down by the members in the filter dimension. Instead, each filter dimension query is supposed to return a single member by which the result will be filtered.

Unlike axis dimension queries, a filter dimension query can return the virtual root member, indicating no filtering should be performed on that dimension. Since all filter dimensions return a single value, the concepts of join type or including/excluding empty values do not apply.

Request Type

Each model contains various types of data, organized in different fact tables. The request type indicates which type of data to retrieve:

Request TypeNumberData TypeFact Table
Kpi0Diagnostic data (trending)B_xxx
Metrics2Metrics/financial dataM_xxx
Stats7Statistics/sales driversS_xxx
note

Not all fact tables are linked to all dimensions in the model. For instance, M_xxx tables will not have a Stage dimension.

Time Perspective

Time perspective is a query parameter that describes how to perform aggregation on the time dimension:

ValueNameDescription
1MTD (Month-To-Date)Default; time aggregation is performed the same way as for other dimensions
2QTD (Quarter-To-Date)Numbers for a period are calculated by aggregating from the first period in the quarter to the requested period
3YTD (Year-To-Date)Numbers for a period are calculated by aggregating from the first period in the year to the requested period

The time balancing rules described in Key Concepts apply for time perspective aggregation as well. The time balancing rules described in Key Concepts apply for time perspective aggregation as well.

Query Object Structure

interface ModelQuery {
Model?: string; // Model to query (default if null)
RequestType: RequestType; // Type of data to retrieve
Axes?: QueryAxis[]; // One or more query axes
Filters?: DimensionQuery[]; // Zero or more dimension query filters
TimePerspective?: TimePerspective; // MTD, QTD, or YTD
}

interface QueryAxis {
JoinType?: string; // Crossjoin or Direct
IncludeEmpty?: boolean; // Whether to include empty member combinations
Dimensions: DimensionQuery[]; // List of dimension queries for the axis
}
MemberDescription
ModelModel to run the query against; use the default model if null
RequestTypeType of data to retrieve (see above)
AxesOne or more axes for the query
FiltersZero or more dimension query filters for the query
TimePerspectiveTime perspective (see above); optional, default value is 1 (MTD)
JoinTypeCan be "Crossjoin" or "Direct"; optional, default is Crossjoin
IncludeEmptyWhether to include empty member combinations; optional, default is false
DimensionsList of dimension queries for the axis