Wee Loon Goh Posted December 13, 2023 Share Posted December 13, 2023 I have a dropdown filter which point to a column's date (Month) column. My visualization will change accordingly base on the dropdown. May I know how do I set the dropdown to automatically choose the latest Month? Thanks in advance Link to comment Share on other sites More sharing options...
Fredrik Rosell Posted December 14, 2023 Share Posted December 14, 2023 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 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 More sharing options...
Fredrik Rosell Posted December 14, 2023 Share Posted December 14, 2023 Attached example dxp file. Link to comment Share on other sites More sharing options...
Tyler Kendle Posted December 15, 2023 Share Posted December 15, 2023 Similar to what Fredrik said here is a Dr. Spotfire video, "Set Default Values in Spotfire when a page loads" that can help show you how to run an IronPython script for setting that default value.Link: Link to comment Share on other sites More sharing options...
Marlina Posted June 27 Share Posted June 27 Hi All, I encounter this error when trying out as above utube. Pls advise how can i resolve this Could not perform action 'reset'. (5) Could not execute script 'reset': unexpected token 'mm' at Spotfire.Dxp.Application.Scripting.ScriptService.Execute(ScriptDefinition script, Dictionary`2 scope, InternalLibraryManager internalLibraryManager, NotificationService notificationService) at Spotfire.Dxp.Application.Scripting.ScriptManager.<>c__DisplayClass8_0.<ExecuteScript>b__0() at Spotfire.Dxp.Framework.Commands.CommandHistory.Transaction(Executor executor, Boolean visible, Boolean sticky, Guid stickyGuid, Boolean isHighlight) at Spotfire.Dxp.Framework.Commands.CommandHistory.Transaction(String displayName, Executor executor) at Spotfire.Dxp.Application.Scripting.ManagedScript.Execute(Dictionary`2 environment) at Spotfire.Dxp.Application.HtmlTextAreaControls.ActionControl.ModifyCore(Object value) at Spotfire.Dxp.Application.Visuals.HtmlTextArea.InteractWithControl(String id, Action`1 interaction) Link to comment Share on other sites More sharing options...
David Boot-Olazabal Posted June 27 Share Posted June 27 Hi Marlina, When do you get the error message? Is that when running the iron python script? Or is it when you try to reset the date? Can you share your scripts, as well as your property control expressions? Kind regards, David Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now