0% found this document useful (0 votes)
35 views8 pages

Tips For Better Benefits From The New Set Expr. Syntax

The document discusses set expressions in Qlik and provides examples of using outer and inner set expressions with aggregation functions. It explains that the inner set expression will inherit the outer set if different dimensions are used, but the inner will take precedence if the same dimension is used in both. Using set identifiers like $ or 1 in the inner expression will cause it to not inherit the outer. Parentheses can be used to define the lexical scope of a set expression.

Uploaded by

Saso Nikolovski
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views8 pages

Tips For Better Benefits From The New Set Expr. Syntax

The document discusses set expressions in Qlik and provides examples of using outer and inner set expressions with aggregation functions. It explains that the inner set expression will inherit the outer set if different dimensions are used, but the inner will take precedence if the same dimension is used in both. Using set identifiers like $ or 1 in the inner expression will cause it to not inherit the outer. Parentheses can be used to define the lexical scope of a set expression.

Uploaded by

Saso Nikolovski
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

#2nd_Post

For Better Benefits


Tips From The New Set
Expression Syntax.

OLD
SUM( {<OrderYear={2022}>} Sales)

NEW
{<OrderYear={2022}>} SUM(Sales)

Qlik
Qlik Let's First Define The
Outer And Inner
Set Expressions.

It’s so simple!

{< Outer Set Expr.>} SUM( {< Inner Set Expr.>} Sales)
Qlik As Long As Different Dimensions Are
Used In The Outer And Inner Set
Expressions, The Inner Set Expression
Will Inherit The Outer Set Expression.
The following expressions return the
same result.

SUM( {< Country = {'Germany'} , OrderYear = {2022}>}


Sales)
{<Country = {'Germany’} >}
SUM( {< OrderYear = {2022}>} Sales)
{< Country = {'Germany’}, OrderYear = {2022} >}
SUM( Sales )
However, when the same dimension is simultaneously used
in both the outer and inner scopes, the inner set expression will
take precedence and override the outer set expression.

The following expression returns the sum of Sales exclusively


for the year 2023.

{< OrderYear = {2022} >}


SUM({< OrderYear = {2023} >} Sales )
Qlik But What Happens If A Set
Identifier Like "$" And "1" Is
Used In The Inner Set
Expression?

{<Country = {'Germany’} >}


SUM( { 1 < OrderYear = {2022}>} Sales)

{<Country = {'Germany’} >}


SUM( { $ < OrderYear = {2022}>} Sales)
In The Following Example The Outer Set Expression
Will Not Be Inherited Into The Inner Set Expression
Since The Inner Set Expression Contains A Set
Identifier. Instead, It Will Inherit The Selection
Because The Set Identifier Used Is "$".

{<Country = {'Germany’} >}


SUM( { $ < OrderYear = {2022}>} Sales)

In The Following Example The Outer Set


Expression Will Not Be Inherited Into The
Inner Set Expression Because The Set
Identifier Used Is “1".

{<Country = {'Germany’} >}


SUM( { 1 < OrderYear = {2022}>} Sales)
Qlik Lexical Scope
Use parenthesis ( ) to define the
Lexical scope.
Without Defined Lexical Scope
The Set Expression Will Be Applied To All The
Upcoming Aggregate Functions. (Red Scope)
{<OrderYear = {2022}>}
SUM(Sales) / COUNT(distinct CustomerID)
- SUM(Profit) / COUNT(distinct CustomerID)

With Defined Lexical Scope


The Set Expression Will Be Applied Only To The Upcoming
Aggregate Functions Enclosed Within Parentheses. (Green Scope)

( {<OrderYear = {2022}>}
SUM(Sales) / COUNT(distinct CustomerID) )
- SUM(Profit) / COUNT(distinct CustomerID)
Qlik Do Not Mix Up The Syntax Of
Set Expressions With The
Syntax Of Functions.

Enclose The Set Expression And The Desired Aggregate


Functions Within Parentheses:

( {< OrderYear ={2022}>} SUM(Sales) ) – SUM(…)

{< OrderYear ={2022}>} ( SUM(Sales) ) – SUM(…)


Feel Free To Share Your
Own Experiences In The
Comments Section!

*Refer to the first comment for more info.

@Abdulhasib_Masri

You might also like