Jump to content
We've recently updated our Privacy Statement, available here. ×

How to set dropdown filter to latest period (month) without the need I manually choose the filter to select latest period whenever there is new data.


Wee Loon Goh

Recommended Posts

Hello,

To my knowledge, there is no out of the box way to do that (I think that would be a VERY good idea for the Spotfire Ideas portal - https://ideas.spotfire.com) but you could e.g. do it with an IronPython script (and exactly how will depend on your exact use case - below you'll find an example that maybe can serve as inspiration for your specific use case)  

In my example:

  • I have a document property - propDate - that contains my "Date" column values.
  • I have a plot "Filtered Data" that only shows data where the date is >= that document property  

Latestdata.thumb.png.b8d059c57131baa23ff0539395e54a96.png 

IronPython script

The IronPython script just gets the max value in the Date column and sets the property to that.

#get the max date maxDate = Document.Data.Tables["data"].Columns["Date"].RowValues.GetMaxValue().Value Document.Properties["propDate"] = maxDate

To trigger the IronPython script to run when the analysis is opened, you can use the Custom DateTime Data Function for TIBCO Spotfire

https://community.spotfire.com/s/article/Custom-DateTime-Data-Function-for-TIBCO-Spotfire

"The main goal of the Custom DateTime Data Function for TIBCO Spotfire® is to enable the running of IronPython scripts on Analysis Open, Filter and Marking changes. The Custom DataTime Data Function allows one to trigger IronPython scripts without having to use a TERR/statistical Data Function for only that purpose."

Using the instructions in the "Executing a Script on Document Open" section there (https://community.spotfire.com/s/article/Custom-DateTime-Data-Function-for-TIBCO-Spotfire#Executing%20a%20Script%20on%20Document%20Open) I can now trigger my IronPython script when the analysis is opened, which results in my filtered plot just showing the latest data.  

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...