How to use a drop down list to dynamically pass columns as the input of a data function

How to use a drop down list to dynamically pass columns as the input of a data function

book

Article ID: KB0082195

calendar_today

Updated On:

Products Versions
Spotfire Analyst All Versions

Description

If you have a data function which uses an input parameter with a Column as the input handler, then if you want to change the column being passed to the data function, you will need to edit the data function parameters each time the column needs to changes. Alternatively, you can use a property control to dynamically select a column and use that document property as the input parameter (for example a document property called "SelectColumn"). But in the Edit Parameters > Expression > Edit dialog, if you only select the document property, with an expression like:
[${SelectColumn}]
Then upon selecting a new column in the property control, the data function may fail to execute with the error:
Could not calculate inputs.
Argument 'myinputparam' could not be type checked.

 

Issue/Introduction

How to use a drop down list to dynamically pass columns as the input of a data function

Resolution

If there are multiple data tables in the analysis file, the expression for the input parameter (as a document property) needs to have the data table included too. Otherwise, the data function will not be able to find the correct column from the correct data table every time you change column from the drop down list.  To avoid the issue, edit the input parameter via:
  • Edit > "Data Function Properties" > Select your data function and click "Edit Parameters" > "Input" tab > Select your input parameter
Instead of using the expression above in the expression input handler, ensure the correct data table is selected in the "Data table" dropdown (for example, with "BASEBALL"), and update the expression to be:
[BASEBALL].$esc(${SelectColumn})
Now after the property control value changes with the selection of a new column, the data function will be able to automatically update using the newly selected column.

See the attached "QQ Plot Data Function Example.dxp" file as an example.

Additional Information

Doc: Details on Edit Parameters:

Attachments

How to use a drop down list to dynamically pass columns as the input of a data function get_app