on 06-02-2022 12:27 PM
Hello,
I would like to create an Array of Objects of my measures in SAC Application designer and then loop thourgh them to check, which of them has to be hidden.
So first I have created an Array:
var measures = [
{
type: "LC",
id:"13UW1NAV5H0KSOI7YHAWV3FPY",
descr: "PY TOTAL @ bud fx"
},
{
type: "GC",
id:"13UW1NAV5H0KSOGFDOPPN4GM9",
descr: "BUD TOTAL @ bud fx"
}
];
So far so good.
Now I would like to loop with the foor loop.
for (i = 0; i < measures.length; i++) {
}
But here I get an error message "Auto-type conversion isnt supported"
I tried to use the following method to define an array. BUt there is no Type "Object" available.
var measures = ArrayUtils.create(Type.Number);
Is there any otehr way to define Arrays? Or to loop of these kind of arrays.
Thank you for help in advance!
I think the error message was because you need to use `var` in the loop:
for (var i = 0; i < measures.length; i++) { }
Regards.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Nikhil,
thanks for your help.
The idea is:
I would like to list a full list of measures within an array. Custom array, not from the datasource.
Then Loop through charts and tables and hide/show measures depending of the users selection, by using some attributes of my array, like "Type"
Br
HErmann
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hermann,
Try something like below.
Add table to your SAC Application. You can hide it if you dont want to display it. Then use below code snippets to get the measure list.
Regards
Nikhil
var measures = Table.getDataSource().getMeasures();
if (measures.length > 0) {
for (var i = 0; i < measures.length; i++)
{ console.log(measures[i].id);} // You can put your logic here...have put console.log as sample
For e.g If want to populate a dropdown with my measure list I can use something like below.
Dropdown_Measures.addItem(measures[i].id, measures[i].description); //Dropdown_Measures is dropdown to populate all measures in my data source.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
81 | |
11 | |
10 | |
8 | |
8 | |
6 | |
6 | |
6 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.