Column and row dimensions
When a dimension is used in a row or column, each of its list items has a heading. A cell is created for every intersecting row and column.
Expand columns and rows in a query
You can use the $expand
option to specify the Column information in the
response:
GET /api/v1/Cubes('Metrics cube-Sales')/Views('Metrics cube-Sales')?
$expand=tm1.NativeView/Columns/Subset($expand=Elements)
In the following results, some results are truncated:
{
"@odata.context": "../$metadata#Cubes('Metrics%20cube-Sales')/Views/ibm.tm1.api.v1.NativeView(ibm.tm1.api.v1.NativeView/Columns/Subset(Elements))/$entity",
"@odata.type": "#ibm.tm1.api.v1.NativeView",
"Name": "Metrics cube-Sales",
"Columns": [
{
"Subset": {
"Name": "All Members",
"UniqueName": "[Metric Indicators].[All Members]",
"Expression": "[Metric Indicators].MEMBERS",
"Elements": [
{
"Name": "Status",
"UniqueName": "[Metric Indicators].[Status]",
"Type": "Numeric",
"Level": 0,
"Index": 1,
"Attributes": { ...
}
},
{
"Name": "Trend",
"UniqueName": "[Metric Indicators].[Trend]",
"Type": "Numeric",
"Level": 0,
"Index": 2,
"Attributes": { ...
}
},
{
"Name": "Actual",
"UniqueName": "[Metric Indicators].[Actual]",
"Type": "Numeric",
"Level": 0,
"Index": 3,
"Attributes": { ...
}
},
...
The Name values of Columns can be seen here:
Use options to expand and filter details
You can expand the rows by using the $expand
option:
GET /api/v1/Cubes('Metrics cube-Sales')/Views('Metrics cube-Sales')?
$expand=tm1.NativeView/Rows/Subset($expand=Elements($select=Name))
In this example, a $select
statement is used to filter the results to only
Name
and UniqueName
:
{
"@odata.context": "../$metadata#Cubes('Metrics%20cube-Sales')/Views/ibm.tm1.api.v1.NativeView(ibm.tm1.api.v1.NativeView/Rows/Subset(Elements+(Name,UniqueName)))/$entity",
"@odata.type": "#ibm.tm1.api.v1.NativeView",
"Name": "Metrics cube-Sales",
"Columns": [
{}
],
"Rows": [
{
"Subset": {
"Name": "All Members",
"Expression": "[metric-sales].MEMBERS",
"Elements": [
{
"Name": "Sales revenue"
},
{
"Name": "Quantity sold"
},
{
"Name": "Order count"
},
{
"Name": "Price discount"
}
]
}
}
],
"Titles": [
{},
{},
{},
{}
],
"SuppressEmptyColumns": false,
"SuppressEmptyRows": false,
"FormatString": "0.00"
}
Columns and Titles aren't displayed because the $expand
option wasn't used in
the expression. The Name values of the Rows are the source for the Row titles in this example:
Create a cube with dimensions and elements
You can create an empty cube initially and then later populate it with dimensions and elements, or you can create a cube with dimensions and elements.
To create a cube and specify the contents of the new cube, specify the context, understand the
structure from the $metadata
document, and use a POST
operation.
To understand the schema rules for a cube, review the definition of the Cube
entity in the $metadata
document:
<EntityType Name="Cube">
<Key>
<PropertyRef Name="Name" />
</Key>
<Property Name="Name" Nullable="false" Type="Edm.String" />
<Property Name="Rules" Nullable="true" Type="Edm.String" />
<Property Name="LastSchemaUpdate" Nullable="true" Type="Edm.DateTimeOffset" />
<Property Name="LastDataUpdate" Nullable="true" Type="Edm.DateTimeOffset" />
<Property Name="Attributes" Type="ibm.tm1.api.v1.Attributes" />
<NavigationProperty Name="Dimensions" Type="Collection(ibm.tm1.api.v1.Dimension)" />
<NavigationProperty ContainsTarget="true" Name="Views" Partner="Cube"
Type="Collection(ibm.tm1.api.v1.View)" />
<NavigationProperty ContainsTarget="true" Name="PrivateViews" Partner="Cube"
Type="Collection(ibm.tm1.api.v1.View)" />
<NavigationProperty Name="Annotations" Type="Collection(ibm.tm1.api.v1.Annotation)" />
<NavigationProperty ContainsTarget="true" Name="LocalizedAttributes"
Type="Collection(ibm.tm1.api.v1.LocalizedAttributes)" />
</EntityType>
The Nullable
attribute identifies the required properties. The
Type
attribute identifies whether the property is one of the built-in types or a
type specific to the TM1 vocabulary. Follow each Type property that is specified by the
NavigationProperty
elements to determine the structure of the entities that are
contained within the cube. For example, the Dimensions
navigation property is
defined as containing items of type Dimension
:
<EntityType Name="Dimension">
<Key>
<PropertyRef Name="Name" />
</Key>
<Property Name="Name" Nullable="false" Type="Edm.String" />
<Property Name="UniqueName" Nullable="true" Type="Edm.String" />
<Property Name="Attributes" Type="ibm.tm1.api.v1.Attributes" />
<NavigationProperty ContainsTarget="true" Name="Hierarchies" Partner="Dimension"
Type="Collection(ibm.tm1.api.v1.Hierarchy)" />
<NavigationProperty ContainsTarget="true" Name="LocalizedAttributes"
Type="Collection(ibm.tm1.api.v1.LocalizedAttributes)" />
</EntityType>
For each entity that is contained within the entity in context, and identified by the navigation
property's Type
value, traverse the model until the full structure of the entity is
understood.
In the following example, a simple cube is created with a minimal number of hierarchies and elements:
POST /api/v1/Cubes
{
"Name": "test_cube_post_dimensions_deep_insert_cube",
"Dimensions": [
{
"Name": "test_cube_post_insert_dimension_1",
"Hierarchies": [
{
"Name": "test_cube_post_insert_dimension_1",
"Elements": [
{
"Name": "test_element_d1e1"
},
{
"Name": "test_element_d1e2"
}
]
}
]
},
{
"Name": "test_cube_post_insert_dimension_2",
"Hierarchies": [
{
"Name": "test_cube_post_insert_dimension_2",
"Elements": [
{
"Name": "test_element_d2e1"
},
{
"Name": "test_element_d2e2"
}
]
}
]
}
]
}
After a successful POST
operation, the context and the new entity that is
created are returned in the response:
{
"@odata.context": "$metadata#Cubes/$entity",
"Name": "test_cube_post_dimensions_deep_insert_cube",
"Rules": "",
"LastSchemaUpdate": "2014-05-06T17:58:49.296Z",
"LastDataUpdate": "2014-05-06T17:58:49.135Z",
"Attributes": {
"Caption": "test_cube_post_dimensions_deep_insert_cube"
}