This code is useful if we have a filtered table and want to populate a dropdown with a subset of values for use filtering elsewhere in the SAC story.
// clear all values from the dropdown and manually add ‘All Members’ as a value Dropdown_1.removeAllItems();
Dropdown_1.addItem("All Members");
/* get the values from the table and loop through all results (members present in the table) from the
Sales_Manager dimension*/
var sel=Table_1.getDataSource().getDataSelections();
for(var i=0;i<sel.length;i++)
{var result = Table_1.getDataSource().getResultMember("Sales_Manager",sel[i]);
/* at each pass of the loop add a result member (dimension member) to the dropdown */ Dropdown_1.addItem(result.id,result.description);}
/* once the loop has finished adding the dimension members, set the dropdown key to ‘All Members’
you could of course set the selected key to any of the other values depending upon requirements*/
Dropdown_1.setSelectedKey("All Members");
Code language: JavaScript (javascript)
The end result should look like this

