on ‎2024 Mar 12 8:58 AM
Dear all,
I am currently struggling with a problem I am not able to solve. I am creating a application (unified story) which has several linked widgets including one table. This table is used as a basis for my scripting.
On Initilization of the script a dropdown with the dimension SAC_Product is populated and this dropdown filters the table:
Table_2.getDataSource().setDimensionFilter("SAC_PRODUCT", Dropdown_1.getSelectedKey());
console.log(Dropdown_1.getSelectedKey());This works fine. In the next step I would like to delete all filters from the product dimension. Currently I am trying to do it with a button for simulation (but it should be done via selecting "All" in the dropdown). So on the click of the button I execute this script:
Dropdown_1.removeAllItems();
Table_2.getDataSource().removeDimensionFilter("SAC_PRODUCT");The dropdown items get deleted but the filter for the table doesnt change. Once I remove the linked analysis from all widgets which are connected to Table_2 this code does work. So it appears with linked analysis the removedimensionfilter() doesnt work. Is this something you have also experienced. Could this be a bug?
As a workaround I have tried the following:
Looping through the dimension and binding all items to an array. Then using this array and .setDimensionFilter() to filter on all items.
This does work for my example with very few dimension members. But I believe that with increasing number of dimension members (large models) the loop itself will cause a lot of time.
Can you help me with that?
Best
Request clarification before answering.
Hi,
here my workaround.
I have a live BW story with multiple charts
I have decided not to use built-in linked analysis because at this point in time .getDimensionFilters returns an empty array if used in combination with linked analysis.
Therefore I wanted to use a users selection within one or multiple charts as basis for filtering.
As users want to change the charts dimensions I initially used standard dimension input controls. However, there is no working API which will return current selected dimension/s directly from the input control.
If the number of used dimensions is very small you could use the workaround from @tablespace described here (he uses input controls to get active selected members). But that was not suitable for my use case as more than 25 dimensions are being used and performance degraded very fast.
That is why I am now using dropdowns instead of dimension input controls because Dropdown_XY..getSelectedKey() always works without problems (to get the current dimension from a chart directly with
console.log(Chart_1.getDimensions(Feed.CategoryAxis));gives back an empty array).
To get a users selection and use that for filtering was a little bit tricky. If you use a charts built-in onSelect method to e.g. console.log() the current selection than you will always get the users selection. But I wanted the user to be able to select one or more dim members in a chart and filtering should only start if he pushes a specific filter button which appears if selection length > 0.
Unfortunately, this does only work if user selects more than 1 member. If only one member is selected and the filter button is pushed the selection is lost. If 2 or more members have been selected and the filter button is pushed => selection is available.
I am now using a global variable for each chart and whenever selection length is > 0 this variable is populated. Function called with charts onSelect method:
var sel = Chart.getSelections();
if (sel.length > 0) {
if (Chart === Ch_1) {
v_Ch_1_sel = sel;
}
if (Chart === Ch_2) {
v_Ch_2_sel = sel;
}
...
...the filter button uses coding below to push the filter to a story filter object:
var FS = Application.getFileDataSource("yourModelID");
//example for chart 1 for simplification
var currentDimID = Dd_Ch_1.getSelectedKey();
var currentDimDescr = Dd_Ch_1.getSelectedText();
// onSelect will be triggered after filter is being set, therfore
// use condition sel.length > 0 to stopt that
if (v_Ch_1_sel.length > 0) {
var filterValues = ArrayUtils.create(Type.string);
for (var i = 0; i < v_Ch_1_sel.length; i++) {
var filterValue = v_Ch_1_sel[i][currentDimID];
if (filterValues.includes(filterValue)) {} else {
filterValues.push(filterValue);
}
}
FS.setDimensionFilterWithHierarchy({id: currentDimID, description: currentDimDescr}, Alias.FlatHierarchy, filterValues);
v_Ch_1_sel.splice(0, v_Ch_1_sel.length);
}with that I have all other objects in the story with the same filter situation and I can use
FS.removeDimensionFilter("dimensionXYZ");to get rid of one or all dim filters.
br
edgar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
linked analysis & unified story still have some limitations
please vote here: getDimensionFilters() for global linked-analysis-filters
if .getDimensionFilters work than .remove... should also be available.
Atm. I prefer not using the built-in linked analysis and use the APIs listed here instead.
br
edgar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 15 | |
| 9 | |
| 6 | |
| 5 | |
| 4 | |
| 4 | |
| 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.