Let’s say we have a dashboard with 3 different data sources for which the user can set the scaling via a dropdown box to either:
(1) No Scaling
(2) Thousands
(3) Millions
If this functionality would be implemented in version 1.3, the script for scaling in the dropdown box would be like this:
If the dashboard would then be enhanced with even more data sources or scaling options, you can imagine it takes some time to adjust this script and it would become even larger.
But with version 1.4 the scaling script can be vastly reduced since the “forEach” loop accepts variables in which data source aliases are stored. This means we can reduce the size of the scaling script to a minimum. The only things that need to be done are storing the data sources in a variable, and for easy use, the selected scaling as well. Then with two “forEach” loops we loop through the data sources and set the scaling for the key figures.
An example is shown below:
The above script works like a charm and as you can see this script in 1.4 is much more compact than the script in 1.3. This makes the script much easier to read and to maintain for the developer.