on 2023 Aug 22 4:11 AM
Hi
Can anyone tell me if it is possible to add a calculated measure to a list within a dropdown widget, in Analytics designer? If possible, can you provide the correct syntax.
Thank you!
mwickman
Something like below, Assuming Table_1 is the table widget and Drodpwn_1 is the dropdown. You can place this code on initialization event or as per your need. This adds both calculated measure from model and story
var measure = Table_1.getDataSource().getMeasures();
console.log(measure);
for (var i=0;i<measure.length;i++)
{
Dropdown_1.addItem(measure[i].id,measure[i].description);
}
Story
Hope this helps !!
Nikhil
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you for the response Nikhil! I should have provided a little more detail. Your method is good for populating all measures, which would include any calculations. However, I have quite a few measures in my model and would like the dropdown list to include only a select few of them, including a calculation. Is it possible to reference a specific calculated measure? Thank you!
mwickman
There can be 2 approaches which I can think of and they depend on how long is the list of measures intended to be added to dropdown. If they are handful, they can be just added manually to the Dropdown widget in the configuration. If the list is a bit long an array variable can be declared to store the list and then a check can be made before assigning them to the dropdown. Below is the adjusted code and I am adding a simple measure, a model level calculated measure and story calculated measure
Dropdown_1.removeAllItems();
var measure = Table_1.getDataSource().getMeasures();
console.log(measure);
var measure_list = ["Flow_Opening_LC","Flow_Total_LC","28757990-1719-4620-3507-315970181928"]; // Add all measure intended here
for (var i=0;i<measure.length;i++)
{
if(measure_list.indexOf(measure[i].id) !== -1 && measure[i].id)
{
Dropdown_1.addItem(measure[i].id,measure[i].description);
}
}
Hope this helps !!
Nikhil
User | Count |
---|---|
68 | |
8 | |
8 | |
6 | |
6 | |
6 | |
6 | |
6 | |
6 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.