The script allows you to select a measure by referencing the measure in a chart expression. The chart expression contains the variable expansion $(=MinString(Measure)). MinString() finds string values in the expression and returns the first text value sorted alphabetically, in this case avg(Sales). This makes it possible to interactively decide (and select) which expression to use in a visualization without accessing and manipulating the properties of the object.
Output
Create the following table in Qlik Sense by using:
Dimension: Dim
Measures:
='$(vSelectMeasure)'
=$(=MinString(Measure))
Avg(Sales)
Table - Dollar-sign expansion using an expression
Dim
='$(vSelectMeasure)'
=$(=MinString(Measure))
Avg(Sales)
Totals
-
260
260
A
avg(Sales)
175
175
B
avg(Sales)
235
235
C
avg(Sales)
370
370
Example: Calculate the quota between two dimensions
Load script
Load the following data as an inline load in the data load editor:
Let vDivision = '=MinString(Numerator) / MinString(Denominator)';
Load recno() as Numerator autogenerate 100;
Load recno() as Denominator autogenerate 100;
Explanation
This script generates a pair of fields, containing 100 values each, that function as Numerators and Denominators in a calculation of the quota between the two. The chart measure contains the variable expansion ='$( vDivision )' , making it possible to interactively decide (and select) which quota to be calculated.
Output
Create the following table in Qlik Sense by using:
Dimensions:
Numerator
Denominator
Measure: ='$(vDivision)'
The resultant quota (Totals) is affected by the selected values in the fields. Numerator (=5) and Denominator (=3) and will be recalculated with each new selection in either field.
Table - Dollar-sign expansion as expression
Numerator
Denominator
='$(vDivision)'
Totals
-
1,6666666666667
5
3
1,6666666666667
File inclusion
File
inclusions are made using dollar-sign expansions. The syntax is:
$(include=filename)
The above text will be replaced by the content
of the file specified after the equal sign. This feature is useful when storing scripts or parts of scripts in text files.
A dollar expansion is normally not sensitive to alternate states. However, if the dollar expansion has an expression, this is evaluated in the state relevant to the object where the dollar expansion is made.
For example:
$(=Sum(Amount))
The calculation will return the sum of amount based on the selection in the state of the object.
Measure
A measure is a calculation base on one ore more aggregations. For example, the sum of sales is a single aggregation, while the sum of sales divided by the count of customers is a measure based on two aggregations.