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.
Interaction between dollar-sign expansions and outer set expressions
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.
When you visit any website, it may store or retrieve information on your browser, mostly in the form of cookies. The information does not usually directly identify you, but it makes the site work as you expect it to and can give you a more personalized web experience. Because we respect your right to privacy, you can choose not to allow some types of cookies by clicking on the different category headings to find out more and change your settings. However, blocking some types of cookies may impact your experience of the site and the services we are able to offer.
Privacy & Cookie Notice
Manage Consent Preferences
Strictly Necessary Cookies
Always Active
These cookies are necessary for the website to function and cannot be switched off in our systems. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms. You can set your browser to block or alert you about these cookies, but some parts of the site will not then work.
Functional Cookies
These cookies enable the website to provide enhanced functionality and personalization. They may be set by us or by third party providers whose services we have added to our pages. If you do not allow these cookies, then some or all of these services may not function properly. These cookies do not typically store personal information enabling us to identify you, but are based on uniquely identifying your browser and internet device.
Performance Cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site and make it easier to navigate. For example, they help us to know which pages are the most and least popular and see how visitors move around the site. When analyzing this data it is typically done on an aggregated (anonymous) basis.
Advertising Cookies
These cookies may be set through our site by our advertising partners to build a profile of your interests and show you relevant advertisements on other sites. They do not typically store personal information enabling us to identify you, but are based on uniquely identifying your browser and internet device. If you do not allow these cookies, you will experience less relevant advertising.