Mapping.Time to Date.Month to Month
The below code builds a mapping from Time elements to Date parent elements. For each Time element in the Month List hierarchy, it maps to the same named element in the Date dimension.
End outcome would be Time:2026 - Jan maps to Date:2026 - Jan.
Process Code
vb
var mapName = "Mapping.Time to Date.Month to Month";
var lDims = ["Time"];
var rDims = ["Date"];
function pre() {
// This function is called once before the processes is executed.
// Use this to setup prompts.
script.log('process pre-execution parameters parsed.');
}
function begin() {
// This function is called once at the start of the process
script.log('process execution started.');
if (mapping.exists(mapName)) {
mapping.wipe(mapName);
} else {
mapping.create(mapName, lDims, rDims, false, true);
}
let months = JSON.parse(hierarchy.rootElements("Time", "Month List"));
for (let i = 0; i < months.length; i++) {
let mon = months[i];
if (element.exists("Date", mon)) {
mapping.rowAdd(mapName, [mon], [mon]);
}
if (script.IsCancelled()) {
return;
}
}
}
function data(record) {
// This function is called once for each line of data on the second cycle
// Use this to build dimensions and push data into cubes
}
function end() {
// This function is called once at the end of the process
script.log('process execution finished.');
}