on 2025 Jan 31 9:46 AM
Hi,
Here is the scenario. I have created a bar graph and user wants to filter this graph by either of the three dimension (Brand, Region, Company Code). I know we can create a standard dimension input control which will serve this requirement but due to some constraint I cannot use the dimension input control. Is there a way, I can create a dropdown and filter the bar graph using the values from this dropdown via scripting. I'm looking at other places also but mostly people are using the dropdown to filter by measures instead of dimension.
Anyone who has faced this similar issue or knows the workaround in this scenario. Their comments would be deeply appreciated.
Request clarification before answering.
This is a very basic example -
*you can enhance the functionality by adding a dimension selector, or automatically taking the dimension
currently present in the chart etc.
In this example we use the Best Run Juice sample model, with a chart containing the Sales Manager dimension.
Widgets:
Chart: Chart_1
Dropdown: Dropdown_1
Steps:
1. Page OnInitialisation event add the script:
Dropdown_1.addItem("All Managers");
var Managers = Chart_1.getDataSource().getMembers("Sales_Manager");
for(var i=0;i<Managers.length;i++)
{Dropdown_1.addItem(Managers[i].id,Managers[i].description);}
Dropdown_1.setSelectedKey("All Managers");
2. In the Dropdown add the script:
var Dropdown_value=this.getSelectedKey();
Chart_1.getDataSource().removeDimensionFilter("Sales_Manager");
if(Dropdown_value !=='All Managers')
{Chart_1.getDataSource().setDimensionFilter("Sales_Manager",Dropdown_value);}
The end result is this
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@JBARLOW , Thank you for your response. But the requirement is to filter by dimension not by dimension members. For example, if there are three dimensions in the model. Brand, Region and Company Code. I want a dropdown which filters the values based on the dimension selected by the users. What I understood from your response is that you are filtering on list of dimension member instead of entire dimension. I would appreciate if you can tell me how can I enhance the dimension selection option.
In which case you need to populate a dropdown with the dimensions, then set the dropdown to switch dimensions in/out of the chart
(With additional code enhancement you can only add specific dimensions to the dropdown)
Populate the dropdown with all dimensions in the underlying model:
var dimlist=Chart_1.getDataSource().getDimensions();
for (var x=0;x<dimlist.length;x++) {
Dropdown_1.addItem(dimlist[x].id,dimlist[x].description);}
Dropdown code to swap the dimension in the chart:
var Dim=Chart_1.getDimensions(Feed.CategoryAxis)[0];
var Key=this.getSelectedKey();
Chart_1.removeDimension(Dim,Feed.CategoryAxis);
Chart_1.addDimension(Key,Feed.CategoryAxis);
Hi @azm_azm,
For Dynamic Dimension Selection On Bar Graph
It will show all dimension on dropdown selection
You can try same with Checkbox group also
Kindly upvote and like if you find it useful.
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 18 | |
| 6 | |
| 6 | |
| 6 | |
| 4 | |
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.