3 Different Ways to… Update a Value in a Filter or Formula Tool
In the third part of the three ways series, I am going to demonstrate three ways to update a date in a filter (the same technique also applies for other tools like a formula tool).
This a great way of updating a value in only one place, either in the workflow or through an interface tool when building analytic apps.
#1 – Action Tool
The first approach follows a similar technique in the other how to guides, by using an action tool to update the value in the filter.
Here the user has to define a fixed value in the formula tool and this is updated when running the workflow as an Analytic App. The configuration of the Action Tool, updates the expression by replacing a specific string.
A downside of this approach is when running the workflow in Designer it will use the hardcoded value. If you want to see what happens in the workflow when you change the value you’ll need to run the Analytic App or run it in debug mode.
#2 – Workflow Constant
The second approach is to set a user specified user constant (click on the canvas, then select workflow in the configuration pane, then click the (+) icon to create a user constant.
In the configuration pane you can either set a value (in this case 2020-10-31), or leave this blank. Then in the formula tool you then replace the date with the user constant.
The benefit of this approach is you can see the impact of changing the value by updating the value in the workflow configuration pane, without having to hard code any values in formulas and run that directly in Designer to see the data flow through the tools.
#3 – Workflow Question
Like the approach of using a user constant, using a workflow question allows you to change the value once in the workflow configuration pane and see what happens when you change it directly in Designer.
An additional benefit of doing it this way is, you can still use the date picker to select the date and run the workflow as an analytic app, whereas in the user constant version you can only change the value in the configuration window.
To set up a workflow question, click on the interface tool (in this case a date picker tool) and then navigate to the annotation pane in the configuration window. Here you need to set a name for the tool (it will default to something like Date (1) which isn’t very intuitive).
Then in the workflow configuration you can set a date, which will be overridden when the workflow is run as an app.
Then in the workflow, there’s two options:
(a) Connect the interface tool to the question input of the filter tool and then type [#1] in the filter tool instead of the date. If you want the date picker to update several tools in the workflow then you’ll need to connect the question output to the input of all of those tools.
(b) Alternatively, the expression can be updated with the workflow question. This is a cleaner option if connecting to multiple tools, however you loose the ease of review of seeing where the values are being updated.