Creating a Dimension via a Process
All of the following functions are documented in full in the Process Documentation section of the portal.
Dimension Functions
When creating a dimension using a process the primary functions needed are:
js
dimension.create(dimName, dimType);
dimension.exists(dimName);
dimension.wipe(dimName);
A typical start to a dimension building process involves
js
//1. Checking if the dimension exists
if( dimension.exists(dimName) == false ) {
//2. If the dimension does not exist, create it
dimension.create(dimName, dimType);
} else {
//3. If the dimension does exist, wipe it
dimension.wipe(dimName);
}
These steps can been combined into a single function:
js
dimension.createOrWipe(dimName, dimType);
Hierarchy Functions
Once the dimension exists, one or more hierarchies are also created. The functions to do this follow a similar pattern.
js
hierarchy.create(dimName, hierName);
hierarchy.exists(dimName, hierName);
hierarchy.wipe(dimName, hierName);
//utility function for all of the above.
hierarchy.createOrWipe(dimName, hierName);
Element Functions (Incl. Parent Elements)
When creating elements within a process. Use the following function to add a consolidation element under another consolidation element.
js
hierarchy.structure(dimName, hierName, parentElement, childElement);
When adding a dimension element under a consolidation element use the following function.
js
hierarchy.group(dimName, hierName, parentElement, childElement);
The dimension process functions are further explained under the Processes Section.
Hierarchy Blueprints
In some instances it is hard to know the depth of a hierarchy from the source data in advance, which makes it difficult to know when to use hierarchy.group
vs. hierarchy.structure
. In this instance there are a set of functions which can be used to build a blueprint of the hierarchy, when this blueprint is saved it will determine which elements will be added as dimension elements or parent elements in the given hierarchy.
js
hierarchy.blueprint.create(blueprintName);
hierarchy.blueprint.add(blueprintName, rootName) ;
hierarchy.blueprint.addChild(blueprintName, parentName, childName);
hierarchy.blueprint.publish(dimName, hierName, blueprintName);
One additional advantage of the Blueprint syste
m is that the same blueprint can be published to multiple hierarchies (incl. across multiple dimensions).
Standard Template for building a Dimension
For information on how scripted processes are structured and how each of the standard functions is used, refer to the Scripted Processes documentation.
js
/**
* Author: example name
* Date Created: 2022-12-15
* Date Modified: 2022-12-15
* Date Deprecated: #N/A
*
* Parent Process: #N/A
* Primary Function: Build the Department Dimension
* Target: Department
* Datasource: CSV file from business users
* Datasource Fields:
* dept - department code
* name - department name
*
* Builds the department dimension from the user
* managed department file.
*/
var dimName = "Department";
var dimType = "Standard";
var parentElement = "All Departments";
function pre() {
//do nothing
}
function begin() {
//create or wipe our dimension
dimension.createOrWipe(dimName, dimType);
//Setup two alternative names for the department elements
alias.createOrWipe(dimName, "Name");
alias.createOrWipe(dimName, "Code - Name");
//create or wipe our default hierarchy
hierarchy.createOrWipe(dimName, "Default");
//create or wipe our "No Department" hierarchy
hierarchy.createOrWipe(dimName, "No " + dimName);
hierarchy.group(dimName, "No " + dimName, "", "No " + dimName);
}
function data(record) {
/* build a hierarchy of elements in the default
hierarchy using the datasource information */
hierarchy.group(dimName, "Default", parentElement, record.dept);
//set the "name" and "code - name" alias.
alias.set(dimName, "Name", record.dept, record.name);
alias.set(dimName, "Code - Name", record.dept, record.dept + record.name);
}
function end() {
//do nothing
}