Creating a Calculation

On this page you will find instructions on how to set up a Calculation.

A Calculation for a chart or indicator allows you to return a value that is calculated on one or more aggregations.

It can be used for example to combine aggregation results from different data pots on a overarching dashboard.

If the Calculation uses data from different data pots it cannot be filtered.

To create a Calculation,

  1. Select the Calculation Button and

  2. click on the Add Button. A new dialogue with the Calculation Editor opens.

  3. Enter a name for the Calculation,

  4. add aggregations via the Add Button. Select an existing aggregation via the Dropdown or create a new one by clicking the Add Button.

  5. Enter a Code for the aggregation that will be used in the Calculation Script and define the attribute of the aggregation that holds its result (e.g. result).

  6. Click on Apply.

     

  7. Enter a Calculation Script in the Calculation Editor that comprises the Code of the aggregation. Below you will find a list of frequently used Calculation Scripts.

  8. Click Preview to check if the Calculation return the result correctly.

  9. Click Save As New.

Calculation Scripts

Sum of results grouped by values

This Calculation sums up all results with the same value across all added aggregation.

// Example // Aggregation 1 {"value": "Female", "result": 20}, {"value": "Male", "result": 15} // Aggregation 2 {"value": "Female", "result": 10}, {"value": "Male", "result": 5} // Result {"value": "Female", "result": 30}, {"value": "Male", "result": 20}

For values to be grouped they need to be spelled identically.

["AGG1", "AGG2", "AGG3", "AGGX"] need to be exchanged by the codes of the added aggregations.

const paramNames = ["AGG1", "AGG2", "AGG3", "AGGX"]; const groupByKey = "value"; groupByKeys = []; // collect all "groupByKey" values from all aggregation results paramNames.forEach(paramName => { this[paramName].map(e => e[groupByKey]).forEach(value => { if(!groupByKeys.includes(value)) { groupByKeys.push(value); } }) }); result = groupByKeys.map(groupCode=> { result = 0; name = ""; paramNames.forEach(paramName => { const entry = this[paramName].find(p => p[groupByKey] === groupCode); result += entry ? entry.result : 0; if(entry && !name) { name = entry.name } }); return { value : groupCode, name : name, result : result }; });

Sorting of results

Descending

resutl = result.sort((a,b) => b.result-a.result);

Ascending

Â