Spectre Flow Calculation List File
The Spectre Flow Calc process node is capable of reading a file containing multiple calculations. This topic shows the format for these calc list files as well as an example and code sample of the file usage. For more information on the calc-list tag, see calc-list.
The calc list file is a tab-delimited file composed of at least two columns. The Name and Expression columns are not optional. All other columns are optional.
| Column Name | Description |
|---|---|
| Name | The name of the column that is added and populated with the calculation results or the column whose values are to be replaced by the calculation results. |
| Expression | The calculation. Format this value like any other calculation value. Do not wrap the calculation in quotation marks ("") or backticks (``). |
| Label | Defines a label for the column. The label is displayed in other products such as DivePort, ProDiver, and Analysis Tables. Optional. |
| Replace |
Specifies if this calculation is adding a new column or replacing the value of an existing column. The value of this column is True when replacing an existing column and False when adding a new column. NOTE: When replacing an existing column, the Name value must match the name of the column being replaced. |
|
Format |
Sets the display format. |
| Required Dimension | Specifies that the column behaves like an Info Field. In ProDiver, this field is available as a column that you can add to other columns displayed in a dive. |
| Time Zone |
Indicates a default time zone to associate with a column when displaying the data. The string should be an ICU time zone name. Use with Format. If this tag is not present, GMT is assumed. For a list of ICU time zone names, see ICU Time Zones. |
| Sort By | Defines a separate column (of the type string or integer) by which to sort the column. For example, a column "Month" with the names of months (January, February, March) and a column "Month Number" with each month's corresponding number from 1 through 12. When you specify "Month Number" in the Sort By column for "Month", that means that the values in "Month" are sorted numerically, instead of alphabetically. |
| Natural Sort | Specifies how numbers contained in strings are sorted. If true, numbers are sorted in numerical order. For example, "A9" comes before "A11" because 9 comes before 11 numerically. If false, numbers are sorted alphabetically. For example, "A11" comes before "A9" because 1 comes before 9 alphabetically. |
An example of a calc list file is as follows:
NOTE:This example is formatted as a table for readability. A calc list file must be tab-delimited.
| Name | Expression | Label | Replace |
|---|---|---|---|
| Profit | value("Revenue") - value("Costs") | False | |
| Order Date | date(value("String Order Date"), "MM-DD-YYYY") | FALSE | |
| Full Name | scan(value("Full Name"), 1, " ") | Seller First Name | True |
An example of that calc list file with the correct formatting is as follows:
Name Expression Label Replace
Profit value("Revenue") - value("Costs") False
Order Date date(value("String Order Date"), "MM-DD-YYYY") Date Ordered FALSE
Full Name scan(value("Full Name"), 1, " ") Seller First Name True
A calc list text file can be created in any text editor. To create a calc list text file in Workbench:
-
Open Workbench and navigate to the project you want to add a calc list text file to.
-
Right-click on the folder you want to create the calc list file in. The context menu opens.
-
Select New > Text File.
A new text file is created.
-
Add your calculations to the text file. The text file must have a header line as the first line, and all values must be tab-delimited. The Name and Expression columns are required, and all other columns are optional.
A calc list file can also be created in a Spectre Flow List code block. An example of a list-input is as follows:
list-input "Calc-List" {
column "Name"
column "Expression"
column "Label"
column "Replace"
row "Profit" "value(\"Revenue\") - value(\"Costs\")" "" "False"
row "Order Date" "date(value(\"String Order Date\"), \"MM-DD-YYYY\")" "Date Ordered" "False"
row "Full Name" "scan(value(\"Full Name\"), 1, \" \")" "Seller First Name" "True"
}
Note that no additional formatting is necessary.
The way to specify a calc list file for use is through an input code block. If you have a text file containing your calculations, use a text-input code block. To define your calculations in a Spectre Flow script, use the list-input text block. Regardless of how you specify your calc list, the way to use that list in a calc code block is by defining a source tag within the calc-list tag.
For example, given a text file, you use a text-input code block that is then referenced as the source for a calc-list tag:
text-input "Text-Input" {
file "text-input.txt"
}
text-input "Calc-List-Text" {
file "calc-list.txt"
}
calc "Calc" {
source "Text-Input"
calc-list {
source "Calc-List-Text"
}
}
Similarly, the way to specify a list-input calc list is by referencing a list-input code block in the calc-list source tag. For example:
list-input "Calc-List-List" {
column "Name"
column "Expression"
column "Label"
column "Replace"
row "Profit" "value(\"Revenue\") - value(\"Costs\")" "" "False"
row "Order Date" "date(value(\"String Order Date\"), \"MM-DD-YYYY\")" "Date Ordered" "False"
row "Full Name" "scan(value(\"Full Name\"), 1, \" \")" "Seller First Name" "True"
}
text-input "Text-Input" {
file "text-input.txt"
}
calc "Calc" {
source "Text-Input"
calc-list {
source "Calc-List-List"
}
}
These examples are available for download as a code sample.
Code Sample: Spectre Flow Calc List
The following download contains two Spectre Flow scripts that run calculations from calc lists. One calc list is an external text file, and one calc list is defined within the script in a list-input code block

Spectre Flow Calc List
NOTE: This Dimensional Insight code sample is available for download. It contains samples scripts and data to demonstrate how a concept works in practice.