Adhoc Selection of Key figures in Lumira
Introduction:
- Lumira generally offers to view or filter the report with respect to the selection of dimensions made by user and if we would like to enhance the selection based on KPI’s the below blog helps us to achieve it.
Use case:
This approach would be useful when user has many KPI’s displayed in the chart and user would like to have control or do the adhoc analysis on the KPI’s selected in a particular chart or all the charts irrespective of the KPI’s displayed initially.
For instance in the Delivery performance chart shown above though the initial displayed KPI’s are Incoming order and Delivered as required Quantity. The user has the flexibility to select the KPI from the list box as shown in the below figure.
To achieve this we need to have a listbox populated with required GUID’S of measures which can be obtained by following the below mentioned .
The GUID’S of the measures can be then used to populate the listbox by following the below step.
Here value column denotes the GUID of the measure and Text is the description of the KPI .
For the listbox to be enabled for the dynamic selection we need to trigger the on select event.
Note : On Select event gets triggered only when the corresponding object is selected and the description is pretty much self explanatory.
//Get the GUIDS of all selected members
var array = this.getSelectedValues();
//This refers to the object which is invoking the function here it refers to Listbox
var array1 = ["ELTUIDCMP12","ELTUIDCMP15"];
//Here array1 is used to capture the restore the values of the chart
//Once the listbox is selected it overwrites the initial view of the report and deselecting all the
//radioboxes generates and empty component . To overcome this we use the length function which checks
//the selection for null values
if (array.length == 0)
{
CHART_1.setDataSelection({"(MEASURES_DIMENSION)" :["ELTUIDCMP12","ELTUIDCMP15"]});
}
//The above if statement is used to revert back the chart to its original state
else {
CHART_1.setDataSelection({"(MEASURES_DIMENSION)" :array});
CHART_1.clearSelection();
}
//Similary the code can be enhanced to restrict other charts as well
//CHART_2.setDataSelection({"(MEASURES_DIMENSION)" :array});
//CHART_3.setDataSelection({"(MEASURES_DIMENSION)" :array});
//CHART_4.setDataSelection({"(MEASURES_DIMENSION)" :array});
Additional info :
In Design studio the same functionality was achieved using checkbox group. But the drawback of the method is for n keyfigures in a checkbox group the combinations used to be n factorial ways. For examples when three keyfigures are used in a checkbox group a user can select the keyfigure in 3! Which is 6 ways and six lines of code has to be made for each combination this approach made almost impossible to code with more than 5 keyfigure as we need to have 5! Which is 120 line of code for each unique combination the user may select.