Calculate fields processor
Adds new fields based on Qlik script expressions.
The Calculate fields processor allows you to create new fields in the schema of your data, and fill each of them using Qlik script expressions. Your script can use everything from the input schema, allowing you to use combinations or transformed versions of existing fields.
Usage
-
The Calculate fields processor requires one input flow and can generate only one output flow.
-
Click the + icon in the processor configuration panel to create more than one calculated field.
Properties
Properties to configure to calculate new fields.
Property | Configuration |
---|---|
Name | Give a custom name to the newly created field. |
Expression | Enter your Qlik script expression in the text editor to set the values of the new field. For more information on the Qlik script syntax, see Script syntax and chart functions. |
To rename the processor or edit its description, click the Edit icon next to the processor name in the Properties panel.
Examples
-
Setting a incremental value to use as id for the new field rows:
RecNo()
For more information, see Counter functions.
-
Using if/then/else conditions. In this example, you have loaded data with temperature, and want to include additional information depending on the values:
If(Temperature <= 0 , 'Freezing', If(Temperature >= 100, 'Boiling', If(Temperature >0 AND Temperature < 100, 'Between')))
For more information, see if - script and chart function.
-
Performing multiple math operations in a single processor. In a dataset containing fields with a number of units sold, as well as the unit price and unit cost, then you can create two new fields for the total revenue and total cost.
-
In the first field, enter total_revenue as the new field name, and the following expression:
[Units Sold] * [Unit Price]
-
Click the + icon in the processor configuration panel to create another calculated field.
-
In the second field, enter total_cost as the new field name, and the following expression:
[Units Sold] * [Unit Cost]
-
For more examples of script expressions, see Regular statements and Script and chart functions.