Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

ATiDD Summary Sheet

Qlik Advanced Set Analysis Advanced Set Analysis

Set analysis can be used in any front-end expression when Set analysis components: Most common Set identifiers:
analyzing sets of data in a Qlik app, and it is not driven exclusively • Set Identifiers – define the initial data set (can be omitted if it’s {$}) {1} All data
by user selections. {1} {$} {$1} {$_1} {Bookmark01} {State1} {$} Current selection (can be omitted)
• Set Modifiers – (Optional) define specific or fixed values in an initial set {$1} Previous selection
Some benefits of using set analysis in a Qlik app are: {$ <Year= {2020}, Region={'USA', 'UK’} > } {$2} Sequential selection made 2
• Provide advanced analysis on specific sets of data that might • Set Operators – (Optional) define operations between sets like: selections ago
not be related with the user selections. {1 - $ <Year= {2020} >} {State1 * $} {$_1} Forward selection
• Allow dynamic solutions and advanced data analysis without OR logic (+) AND logic (*) Exclusion (-) XOR logic(/) {BM01} Bookmark BM01
much performance impact or complex scripting*. {State1} Alternate state called State1
Set identifiers are always define with curly
*Note: Set analysis is not supported in the data load script.
brackets {set}

Set analysis syntax: FunctionName( {set} expr) Advanced set modifiers:


Searches and advanced Searches:
Qlik expression examples: Sum( Sales ) Double quotes can be used to represent a value search in a field, where several values could be returned:
Count( DISTINCT OrderID) sum( {$ <OrderYear={">=2018" } >}Sales
Concat( DISTINCT Country, ',') sum( {$ <Region={"*America" } >}Sales
Examples using set analysis: Special characters for searches can be used ( *, ?).
Sum({1< OrderYear ={2020} >} Sales) Advanced searches can be defined using double quotes with a equal sign: "= expression’’
Count({$< DeliveredFlag ={1} >} DISTINCT OrderID) Sum({<OrderID= {"=(OrderDate=DeliveryDate)" } >} Sales)
Concat({1} DISTINCT Country, ',') sum( {$ <Customer={ "=sum(Sales)> 50000" } >}Sales
sum( {$ <Product={ "=rank(sum(Sales),4)<=20" } >}Sales)
Set modifiers with expressions and variables:
Working with user selections: Qlik set modifiers can define dynamic values in a field using expressions or variables.
User selections are represented by the {$} set identifier. • Using variables: use $(variableName) as value in the set modifier.
If this is omitted user selections will be applied to the calculation. sum({$ < OrderYear ={ $(vLastYear) } >} Sales )
count({$ < OrderDate ={'$(vLastOrderDate)' } >} DISTINCT OrderID)
• Avoid user selections in all the data set, using the {1} set. • Using expressions (with dollar sign expansion):
• Avoid user selections in a specific field, including all values in the sum({$ < OrderYear ={ $(=max(Year)) } >} Sales )
field, using a set modifier without specifying any values in the count({$ < OrderDate ={'$(=Date(Max(OrderDate), 'DD/MM/YYYY')'}>} DISTINCT OrderID)
field: P() and E() functions:
Sum( {$< Field1 = >}Sales ) • P({set} field) - represents the possible values of a field associated with a selection or set.
• Avoid user selections in a specific table, including the list of fields sum( {$ <Customer=P({1<Product={'Shoe'>} Customer) >}Sales
with empty sets, using the Concat expression: • E({set} field) - represents the excluded values of a field within a selection or set.
Sum({< sum( {$ <Customer=E({1<Product={'Shoe'>} Customer) >}Sales
1
Note: Advanced search expressions, expressions defined in Dollar sign expansion, and expressions in variables can
$(='['&Concat({<$Table={'TABLE1'}>}$Field,'],')&']’)
>} Sales) also include set analysis. P and E functions can include advanced set modifiers.

You might also like