Running Calculations
A calculation whose execution is On Demand or Automatic is compiled to a stored procedure, and can be run on request. Dynamic formulas are evaluated at query time and cannot be run.
| From | Runs as | When |
|---|---|---|
| The Run button in Settings → Model Definitions → Calculations | the user who clicks it | now, in the background |
| A calculation trigger on a dashboard widget (Matrix, Table, Pivot Table, Form) | the user who saves the widget | before or after each save |
| A workflow Run Calculation activity | the user who started or scheduled the workflow | when the workflow reaches it |
All three go through the same checks and offer the same parameters. A calculation can only be chosen once it has been compiled without errors; after a change to a calculation, compile it again.
Every calculation receives the user it runs as. You do not pass it, and it is not shown among the parameters. A username entry left in an older workflow task or trigger is ignored.
Parameters
When you choose a calculation, its parameters appear as fields. What they are depends on the type of calculation:
| Calculation | Parameters |
|---|---|
| Calc script | every param the script declares. All of them are required, and their values are text. |
| SQL calc | the parameters of the procedure after @username, with their SQL type. A parameter with a default is optional. |
| Formula (On Demand / Automatic) | the scope of the run: for every dimension other than the one the formula targets, a member and a relationship. Left empty, the run covers the whole dimension. |
| Model calc | its member parameters, by dimension — see Model Calcs. |
- A required parameter is marked with
*. A run that does not supply it is refused. - A parameter that refers to a dimension is a member picker. A formula's member also has a relationship: Self, Self and descendants (the default), Descendants or Leaf descendants. The scope you give is combined with the scope configured on the formula itself: the run covers what is in both.
- An optional parameter left empty takes its default.
- Numbers, dates and true / false values are checked against the parameter's type before the calculation starts.
Before a calculation runs, Una refuses the run — with a message naming the parameters — when a name is not one of the calculation's parameters, a required parameter has no value, or a value is not of the declared type.
The Run Button
In Settings → Model Definitions → Calculations, each calculation that can run has a Run button. It opens a dialog with the parameters. The calculation then runs in the background, and a notification tells you when it completes or fails; a failure carries the database's message.
Running a calculation from this screen requires the Model Management permission.
Dashboard Triggers
In a widget's editor, the Triggers tab lets a save start a calculation: add a trigger, set its type to Calculation, choose the calculation and fill in its parameters.
A parameter value can be fixed, or it can use the dashboard's variables, so the calculation runs for what the user is looking at:
Scenario = {Parameter.Scenario.0.Key}
Year = {Global.CurrentYear}
- Type
{in a value to pick a variable: the dashboard's filters, its variables, the global variables and{Model}. - For a member, use the
{ }button next to the picker to switch between picking a member and entering a variable. - If a variable has no value when the widget is saved, the calculation does not run, rather than run over everything.
The save does not wait on the outcome of a trigger: a calculation that fails or is refused does not undo the save.
A Form widget that is linked to a Table widget does not save on its own: its changes are saved by the table, and the table's triggers run. Set the triggers on the table; the form's Triggers tab says so. A form that is not linked to a table has its own triggers.
Workflows
See the Run Calculation activity. Parameter values can use the workflow's variables.
After a Run
A run that writes model data is audited like any other write, and it starts the automatic formulas that depend on what it changed.