Number Hierarchy Script Token Not Linking to Source Hierarchy

I have a dataset that has an integer (int16) column that holds the entry week for KPIs.

image

I want to set up a filter token that has it display only the data through last week

This works fine, and shows the weeks going from 1 to 47, however the visualization fails.
image

If I then click and change it to 47 by hand, it works fine.

It makes me think there is some data type mismatch, but I have tried the token as a double and string, (as well as changing the source data type to match those) and it still fails. Any suggestions from the community?

Hi Christopher,

When filtering a hierarchy’s values, and especially when using a hierarchy filter like I think we can see in your last screenshot, the script token likely needs to have its Data Type set to Hierarchy as yours is but then a MemberValue is expected, and that’s constructed out of a hierarchy’s & hierarchy member’s unique names. With this setup, part of your script probably needs to look similar to this, calling one of the MemberValue constructors:

MemberValue[] result = new MemberValue[2];
result[0] = new MemberValue("EntryWeek", "1.A.EntryWeek", "A.EntryWeek", 0);
result[1] = new MemberValue("EntryWeek", week + ".A.EntryWeek", "A.EntryWeek", 0);
return result;

This should allow the filtering to work. It’s possible though that you will see the hierarchy unique names displayed inside the filters when this token is selected, which seems to be a known issue for script tokens with the hierarchy data type. If so, you can ask to be added to the ticket tracking this (93202).

An alternative could be to filter by these week numbers directly if they can be exposed as a public numeric parameter from any of the transforms in a data cube before the Process Result, or converted to a number, and then a Range Number filter could be used with it. In that case the script token’s Data Type could be set to Numeric and the script can return the week numbers directly like yours currently does.