cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Change Story filter programmatically

RoccoCaliandro
Explorer
0 Likes
744

I everyone,

I am new in SAP Analytics Cloud BTW, I am using a story filter (at the left of the story) called HistoryType as  you can see from the screenshot:

RoccoCaliandro_0-1743608635216.png

I also created a listbox and I would like to change the filter as soon as I select something from the list. Is it possible to do that or I should use something else?

Accepted Solutions (1)

Accepted Solutions (1)

DenisT
Explorer
0 Likes

Hi @RoccoCaliandro,

yes that´s quite easily possible. If you just click on the three dots in the top right of your listbox, you´ll get the option "Edit Scripts", which will open the code editor for an "onSelect()" function.

Please enter the following coding:

Application.getFileDataSource("xxx").setDimensionFilterWithHierarchy("yyy", Alias.FlatHierarchy, ["zzz"]);

xxx is the ID of your DataSource. DataSource refers to the data model you´re using. Please notice, that you need the ID, not the technical name or description. The easiest way to get the id is just pressing CTRL+Space after entering: "Application.getFileDataSource(". This will open a popup, where you can select of all data models that are currently part of your story.

The same goes for the yyy, your dimension (in your case something like "HistoryType"). Just press CTRL+Space here again.

Last but not least the same CTRL-Space action for the zzz, the values you want to filter "History Type" to.

Best regards,
Denis

PS: If this solution helped you, please mark it as "accepted solution", thanks.

 

 

Answers (1)

Answers (1)

Ivan_Camac
Participant
0 Likes

Hi,

Yes this is possible. Look at using Application.getFileDataSource().setDimensionFilterWithHierarchy(). Sorry, I don’t have an example handy as I’m away from my laptop. You do need to provide a hierarchy with this method, but you can supply Hierarchy.Flat constant (sorry doing this from memory, so check context help for exact detail). 

Cheers, Ivan.