Jump to content

How can I check the values of Hierarchy filter using Iron Python


Rupinder Kaur

Recommended Posts

Hi,

I want to select the values from Hierarchy filter and uncheck the other values using Iron Python. I am trying the following code but getting stuck.

In a hierarchy filter data is coming from last 2 years from 2017. I want to uncheck 2017 nodes and select 2018 nodes on page by default.

Hierarchy filter looks like:

2018-Q1-Jan-1 (Year,Quarter,Month,Week)

I get no result when running the following script. It runs ok if I want to check/uncheck All nodes but chFilter.Check(DistinctDataValue(2018) line is not giving any result.

from Spotfire.Dxp.Application.Filters import *

from Spotfire.Dxp.Data import *

from Spotfire.Dxp.Data import DistinctDataValue

myPanel = Document.ActivePageReference.FilterPanel;

myFilter = myPanel.FilteringSchemeReference.DefaultFilterCollection["Time"];

chFilter = myFilter.As[CheckBoxHierarchyFilter]();

# Checks all nodes

chFilter.CheckAllNodes()

# Uncheck all nodes

chFilter.UncheckAllNodes()

chFilter.Check(DistinctDataValue(2018),DistinctDataValue(1),DistinctDataValue(2),DistinctDataValue(3))

#chFilter.Check(DistinctDataValue("2018"),DistinctDataValue(1),DistinctDataValue("2"),DistinctDataValue(3))

Anybody knows how can I do that

Thanks,

RK

Link to comment
Share on other sites

  • 1 year later...

Please use the below script to check the filter

from Spotfire.Dxp.Application.Filters import CheckBoxHierarchyFilter

from Spotfire.Dxp.Data import *

# Get the Filter

myPanel = Document.ActivePageReference.FilterPanel

# select the data table number in TableGroup, ie 0 is the first data table

myFilter1= myPanel.TableGroups[0].GetFilter("hierarchy_filter_col")

filter1 = myFilter1.FilterReference.As[CheckBoxHierarchyFilter]()

 

# Uncheck all nodes

filter1.UncheckAllNodes()

#in the value use correct formatting,ie number 2018 and string in "Apr"

filter1.Check(DistinctDataValue(2018),DistinctDataValue("Apr"))

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...