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

Can Story custom date filter be controlled by scripts?

PM8
Participant
1,546

Can Story custom date filter be controlled by scripts? if Yes, can you please provide the code? I am new to scripts.

Accepted Solutions (0)

Answers (1)

Answers (1)

FxGk
Participant
0 Likes

Hey,

if you try to use this date filter by range:


It seems the method getActiveSelectedMembers is not supported for time filters. But:
If you use the "Filter by Member" you can use the script to control it with buttons or what ever you like.
To test it i used the BestRunJuice Model and I set up a chart, a button and the "Filter by Member":

The onClick event of the button executes the following script:

InputControl_1.getInputControlDataSource().setAllMembersSelected();     // to make sure to get all members
var members = InputControl_1.getInputControlDataSource().getActiveSelectedMembers(); // save all members in a variable


// that is the structure of a MemberInfo: 
//			{id: '[Date_703i1904sd].[YHM].&[201606]', dimensionId: 'Date_703i1904sd', description: 'Jun (H1/2016)', displayId: '201606'} 


var selMembers = ArrayUtils.create(Type.MemberInfo); // create an empty Array 

for(var j = 0; j<5; j ++){             	// here you are free to select what ever you want
	selMembers[j] = members[j+3];	// make sure not to select the first one because you would select "all" too
}

InputControl_1.getInputControlDataSource().setSelectedMembers(selMembers); // set the selectet Members<br>

After executing the script it looks like this:

In the loop part you could also check for some properties of the MemberInfo like displayId. Maybe some regex magic can help here.

I hope that is what you are looking for

Regards

Felix

PM8
Participant
0 Likes

thank you for trying, but may not work for my scenario. I appreciate your efforts.

FxGk
Participant
0 Likes

What is your exact scenario?

Blair_K
Product and Topic Expert
Product and Topic Expert
0 Likes
I'm not sure exactly why your proposed solution won't work for PM8, but it won't work for me because your solution uses a standard input control. What I think PM8 is looking for (me as well) is a solution that uses the Current Date Input Control that gets created using a date selection in a Restricted Measure. Typically I use these to specify a date (fiscal year for example) in 1 column, and then provide an offset in subsequent columns. I have not found a solution for this scenario.