Business Intelligence Tools / Developers Corner

Iron Python in Spotfire — Using a property control to change filtering schemes

  • Are you just learning how to use IronPython in Spotfire?
  • Would you like to be able to toggle between Filtering Schemes but are worried about users breaking something?

Filtering schemes are extremely useful for changing multiple filters at one time.  However, if many users are working with a single file, it’s very easy for a single user to alter something that shouldn’t be altered.  This is when I like to use a filtering scheme drop-down property control in conjunction with an Iron Python script to toggle between filtering schemes and have the filtering schemes be left alone.

Filtering Scheme Example

In the example shown in the video, I have three filtering schemes — Well Group A, Well Group B, Well Group C – that have different wells selected in the filter panel.  The video will follow the steps shown below, using the code that is below the steps.



  1. Create your filtering schemes.
  2. Add a text area to the page
  3. Toggle the text area into edit mode.
  4. Click the Add property control button and select drop-down list
  5. Click the New button to create a new property called FilteringSchemes using a string data type
  6. Select Fixed values in the Set property value through: drop down
  7. Under settings, in the Display Name, type – Julie’s wells, Amber’s wells, Kendra’s wells .  This is what will show up in the drop down.
  8. Under Value, type – Well Group A, Well Group B, Well Group C. The case must match the filtering scheme exactly.
  9. Go to the FilteringScheme property, click the Script button.
  10. Set the radio button to Execute the script selected below:
  11. Click the New button and create a script called SchemeSelection
  12. Paste the script into the Script dialog
  13. Click the Add button and add a new Script Parameter MyFilterScheme.
    1. Note MyFilterScheme is part of the code that we just copied and pasted.
  14. Select String in the Type
  15. Set the radio button to Property and click the Select Property button
  16. Select the FilteringSchemes property just created
  17. Click OK
  18. Always click the Run Script button before exiting. That will tell you if the script is working.  If you get errors, work through fixing.  You may or may not be able to see the change if the script runs correctly, depending on what you have coded.
  19. Click OK, click OK and click OK

Here is a screenshot of the script so you can see what the spacing looks like.

Filtering Scheme Drop Down Script


9 thoughts on “Iron Python in Spotfire — Using a property control to change filtering schemes

  1. Ryan James Reply

    Is there a way to set the drop down list with all the current Filtering Schemes programatically? The idea would be able to change and create filtering schemes from the text box rather than with the filtering tab, but I don’t want to have to create a drop down list manually every time.

    • Lucas Wood Reply

      I don’t believe you have access to that dropdown to programmatically add choices. One way you could achieve this is to use javascript to create your own dropdown and then push the changes to a text input, additionally salvaging the configuration you already have. I can try it in a blog this week but at a high-level:

      1. create a ‘reset dropdown’ button that fires an ironpython. this ironpython sets a doc property to all the filterschemes concatenated
      2. create a javascript that waits for that docprop.
      3. whenever that docprop changes, it builds a custom dropdown with all those choices.
      4. when the user makes a choices, jquery detects the blur() action and fires the original ironpython script.

  2. guido Reply

    Hi, is there a way of having an script that send a value to a dropdown (in a different view) in order to go to that page and with a filter value?

    the use case will be: I have a table with the accounts and their high level metrics, I want to be able to click on an specific account and go to a different view (detailed) but filtered by the selected account (in this case the filter for the account its a dropdown

  3. Steve Piper Reply

    Can this be adapted so that the change of filtering scheme is applied to multiple tabs in the dxp rather than just the active tab?
    How would the IronPython script need to be changed to do that?

    • Julie Schellberg of Big Mountain Analytics, LLC Post authorReply

      It could be adapted for that purpose. You would need to add a parameter(s) that specifies the page(s) it should be applied to.

  4. Tammy Reply

    I tried this script and got an Error that “name “filteringSelection” is not defined” How do I fix this? Also, do you have any more detailed directions on how to implement what Steve Piper was wanting to do? I am needing this same thing, but I am very much a spotfire novice. Thanks!

    • Julie Sebby Post authorReply

      “filteringSelection” is used in the 6th line of code. Are you sure that the bit in parenthesis after filteringSelection is spelled correctly and has the correct case? I would think this error could happen if it was misspelled and/or the parameter wasn’t setup. Do you have the parameter?

  5. Jim Reply

    I have implemented the script and followed the instructions but for some reason when I select the second schema from the drop down the page continues to display the first filtering scheme only. Any idea why this would be happening?

    Thank You

    • Julie Sebby Post authorReply

      It sounds like one of the parameters or controls isn’t being recognized. When I worked with this code, I always had to be super careful about caps and plurals (or MyFilterScheme versus MyFilteringScheme). It was very easy to have a naming error. Consider changing some of the variable names to make it easier to QAQC.

Leave a Reply

Your email address will not be published. Required fields are marked *