0% found this document useful (0 votes)
222 views19 pages

Qlik Set Analysis Primer

This document provides an overview of set analysis in Tableau. It discusses: 1. Set analysis allows defining groups of information independently of current selections through set expressions between curly braces. 2. Set expressions can create sets based on other sets and modify the record set context only during the expression that uses the set. 3. The syntax of set expressions includes a set identifier, optional set modifiers with filters, and set operators to allow interactions between sets. 4. Examples demonstrate using set identifiers, modifiers with fields, operators, and the P() and E() functions to select indirect sets based on other field selections.

Uploaded by

shilpan9166
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)
222 views19 pages

Qlik Set Analysis Primer

This document provides an overview of set analysis in Tableau. It discusses: 1. Set analysis allows defining groups of information independently of current selections through set expressions between curly braces. 2. Set expressions can create sets based on other sets and modify the record set context only during the expression that uses the set. 3. The syntax of set expressions includes a set identifier, optional set modifiers with filters, and set operators to allow interactions between sets. 4. Examples demonstrate using set identifiers, modifiers with fields, operators, and the P() and E() functions to select indirect sets based on other field selections.

Uploaded by

shilpan9166
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/ 19

Set A Set B

Set Analysis Primer


Created by: Shilpan Patel, Co-founder, Analyticshub.io/academy/
Why Set Analysis?

Aggregation functions normally aggregate over the set of possible records defined by the
current selections and dimensions.

sum( Sales )

But an alternative set of records can be defined by a set expression.

A set expression starts and ends with a pair of curly braces {}

sum( {$<Year={2008}>} Sales )


Set Analysis -What?

1. Conceptually similar to a selection.

2. Provides a method of defining groups (sets) of information that are independent of the current selections.

3. Can create sets based on other sets.

4. Must be used in an aggregation function.

5. Always begins and ends with curly brackets {}

6. A set modifies the context only during the expression that uses it.

7. Set Analysis expression is calculated once per chart and not for each row.
Set Analysis Syntax
Three Components Two curly braces:
Set identifier (defines scope of {} Outer curly braces for the
the record set) Required record set
Set modifier (adds filters) {} Inner curly braces for the
Optional element set
Set operators (allow interactions <> Modifiers
between sets)

Assignment operator
There is always an = sign between the field name and element set in the
Field name
modifier

Sum ({$<Salesperson = {‘John Doe’}>} Sales)

Set Identifier Set Modifier


Set Identifiers
Set Identifiers
Set Identifier: Examples

◉ sum({1 - $} Sales)
Returns sales for everything excluded by the current selection.

◉ sum({$ * Bookmark01} Sales)


Returns sales for the intersection between the current selection and the bookmark “Bookmark01”.

◉ sum({ - ($ + Bookmark01)} Sales)


Returns sales excluded by current selection and the bookmark “Bookmark01”.

◉ sum({Group1} Sales)
Returns sales for selections made in filters with alternate states ‘Group1’
Set Modifiers: Examples

◉ count( {1 - $<Modality= {‘Radiology’} >} PatientID )


Returns Radiology patient count excluding the current selections but not dimensions.
◉ sum( {$<Year = {2000}, Region = {‘US’, ‘SE’, ‘DE’, ‘UK’, ‘FR’}>} Sales )
Returns the sales for current selection, but with new selections both in 'Year' and in
'Region’.
◉ sum( {$<Year = {"2*"}>} Sales )
Returns the sales for the current selection, but with all years beginning with the number .
Since this is a Year field, it is for all years from 2000 onwards.
◉ sum( {$<Year ={"2*","198*"} - {2000}>} Sales )
As above, but also the 1980’s are included in the selection, but the year 2000 is
excluded.
Set Modifiers: Key Concept

Set Modifier stars and ends with < >

>
Selections

< Field Name


or
Expressions

Not a comparison operator; it’s an assignment operator


Set Operators

Union Returns the set of all records that


+ belong to the unioned sets

Exclusion Returns records that belong to the


- first but not the other of the two
set identifiers.

Intersection Returns records that belong to


* both of the set identifiers.

Symmetric Returns a set that belongs to


/ Difference either, but not both of the set
identifiers.
Interesting Operators: Examples

Exclusion Union Intersection Symmetric Difference

A B A B
A B A B

< [Category Name] -= {'Seafood'}> < [Category Name] += {'Seafood'}> < [Category Name] *= {'Seafood, ‘Beverages'}> < [Category Name] /= {'Seafood'}>

Removes Seafood category from the user selection Includes all selected categories plus Seafood Excludes all categories but Seafood and Beverages Includes all categories but Seafood
Indirect Set Analysis using P() and E() functions

◉ Set analysis was previously restricted to stating direct selections in a field.

◉ It is now possible to state selections in a field based on selections in another field.

◉ The functions p() and e() can be used to select the set of possible or excluded values
within a field.

P() = possible values in a field based on the current selections as an element set
E() = excluded values in a field based on the current selections as an element set
Indirect Set Analysis using P() and E() functions
Sum( {<CarManufactureYear = p(CarManufactureYear)>} [Annual Premium])

This expression will calculate sum of annual premium for


the years that user has selected(in green color) as a set
of filter values. ( Year = 1976 or 1978 or 1980 or 1981 ).

Possible
(white)
Selected(green)

Excluded
(dark
grey)
Advanced Set Analysis
Aggregation as an element set values

In this set expression, sum(sales) > 500000 is used as an


element set values.

You have to use an equal sign before the aggregation function.

Expression search also has to be enclosed in pair of double


quotes
Advanced Set Analysis
Slope Graph with a range expression as an element set

In this set expression, a Year range expression with


Dollar-sign expansion is used in the element set.

You have to use an equal sign before the expression


In the dollar-sign expansion. $(=expression)

Expression search also has to be enclosed in pair of double


quotes
Remember!

String values Numeric values Expressions or Search

Require single quotes Do not require single Require double quotes


within the element set. or double quotes

Example: Example: Example:


< SalesPerson = {‘Joe’}> < OrderID = {1001}> <Year = {“>=2011"} >
<Year = {“(2009)|(201*)”}>
Under the hood

Data set Element Record set


values Set values values

LHS of the modifier RHS of the modifier Aggregation


Let’s review some concepts

Modifiers are sets too! = Sign in the modifier Two Curly braces {}

Remember that both LHS and Is not an equal sign. It is an Outer curly braces for the
RHS of the modifiers are sets assignment by association record set and inner curly
braces for the elementset

< > Angle brackets Quotes Mixed state

Modifier starts with left angle Litteral values need single Record set can be in a default
bracket and ends with right quote; search string or state while element set can be
bracket. expression requires double in different state such as
quotes and numeric values alternate state.
require no quotes.
Thanks!
Created by:
Shilpan Patel, Analyticshub.io/academy/

Contact us for a LIVE one day Set Analysis


Workshop

You might also like