Bitmetric Friday Qlik Test Prep – Week 5 – Set Analysis – Solution

By Bitmetric Admin

Every Friday at Bitmetric we’re posting a new Qlik certification practice question to our LinkedIn company page. Last Friday we asked the following Qlik Business Analyst certification practice question:

No alt text provided for this image

There was a little catch to this question, which fooled exactly no one 😉

The correct answer is C: 65%

Even though the Business Analyst selected the year 2022, that selection is ignored because the expression uses the 1 Set Identifier in the Set Analysis statement (or Set Expression). In fact, when using 1 as your Set Identifier, all selections are ignored. This means the expression is calculated for the entire data set.

In our question, the result is that we have to take not only Feb 2022 into account, but also Feb 2021. From the table we can get the values for Sales (250 + 250 = 500) and Cost of Goods Sold (50 + 125 = 175). Plugging these values into the expression gets us (500 – 175) / 500 = 0.65, or 65%.

Set Identifiers

As mentioned above, the 1 used in the Set Expression is called a Set Identifier. You can think of the Set Identifier as the ‘starting point’ for the data that is included in your Set Expression. This data set can be further modified using a Set Modifier. For example using the <[Month]={‘Feb’}> modifier from the question. This sets the selection in the Month field to Feb. We’ll cover Set Modifiers another time though.

Common Set Identifiers

Besides 1, there are a few other common Set Identifiers:

  • $ refers to the current user selection in the default state (i.e. not an Alternate State). If you don’t specify a Set Identifier, Qlik assumes $ by default. There’s a catch though, more on that later.

  • $1 refers to the previous user selection in the default state, as if you pressed the Back button. $2 refers to 2 selections ago, $3 refers to 3 selections ago, etc.

  • $_1 refers to the next user selection in the default state, as if you pressed the Forward button. $_2 refers to 2 selections forward, $3 refers to 3 selections forward, and so on. This identifier, and the previous one, typically see very little use in our projects as we find that users typically don’t want to compare current to previous selections. Rather, they want to make comparisons between multiple independent selections, which we’ll cover another time.

  • Bookmark, you can use either the Title or the ID of a bookmark to refer to the selection stored inside it.

  • Alternate State, you can use the Name of an Alternate State to refer to the selection within the state.

Fun aside, Qlik will (sensibly) not let you create an Alternate State named $, but will let you create states named 1, $1 or with the same name as a bookmark title. This can lead to strange behavior as the clip below shows.

No alt text provided for this image

When creating an Alternate State named 1, Qlik still interprets the 1 identifier as referencing the entire data set. However, when creating states named $1 or My Bookmark (which has the same name as a bookmark in the app) these identifiers now reference the Alternate States $1 and My Bookmark, and not the previous selection or the selection stored in the bookmark. Best to not mix up Set Identifiers and Alternate State names 😉

Leaving out $ assumes the current user selection

As mentioned above, when you don’t specify a Set Identifier, Qlik assumes the current user selections. Many developers take this to mean that $ and no identifier are identical. Seeing an opportunity for lazine… er, efficiency, some may opt to just leave out $ when they want to refer to the current user selections.

The catch is when you leave out the Set Identifier, Qlik assumes the current user selections for the inherited state. When placing an expression without a Set Identifier in an object that is in an Alternate State, Qlik will use the current user selections in that state, rather than the default state. The clip below illustrates this.

No alt text provided for this image

Is this a bad thing, to be avoided at all cost? No, definitely not, but it’s good to be aware of the difference. Leaving out a Set Identifier can even be very convenient if you want to use a Master Measure containing Set Analysis across objects that are in different Alternate States.

That’s it for this question! See you next Friday? If you’re looking for some more fun things to check out this week then maybe consider:

  • PinIt, our free, self-service mashup generator. Now anyone can quickly combine visualizations and data from across Qlik Sense apps to get the personalized overviews they need. Your users will love you for it! We have a new release coming up later this week.

  • The Bitmetric Qlik Sense Coding Conventions, find out how we keep our scripts readable and maintainable by downloading this free document.

  • Our colleague Angelika collaborated with Vizlib to bring you the Data Literacy how-to guide Data Literacy: How to make data every employee’s friend, another free download.

  • For Qlik and data enthusiasts based in The Netherlands only (sorry!), did you know we have multiple job openings? If you want to build cool and inventive data solutions, value craftmanship in your work, want to learn, grow, create and share knowledge and are also a nice person (some slight quirks accepted 😉), then we’d love to chat with you!

Previous posts

Week 4: Time series visualization

Week 3: Circular References & Synthetic Keys

Week 2: Section Access

Week 1: Optimized Load

About The Author

Bitmetric Admin

Blog posts from the Bitmetric team. At Bitmetric, Qlik is what we do. We've been doing it for years, and we can do it for you! ;)

Leave a Reply

Your email address will not be published. Required fields are marked *

Read previous post:
Friday Qlik Test Prep – Week 4 – Time series visualization – Solution

Every Friday at Bitmetric we're posting a new Qlik certification practice question to our LinkedIn company page. Last Friday we asked...

Close