Bitmetric Friday Qlik Test Prep - Week 5 - Set Analysis - Solution
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:
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:
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.
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.
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: