Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
Jennell_Yorkman
Employee
Employee

The Pick function is a chart and script function that can be used to return the nth expression in a list based on a field or value. It is a good alternative to a large or nested If statement where each If statement needs to be evaluated. With the pick function, one value is read to determine which expression should be returned.

The syntax of the pick function according to Qlik Help looks like this:

pick(n, expr1[ , expr2,...exprN])

The first parameter (n) should be an integer. Based on this value, the first expression, second expression, third expression or nth expression is returned. Let’s look at an example. In the table below, there are three dimensions listed – the state abbreviation, the state name and a state code for the U.S. region the state is in.  One is the Northeast region, 2 is the Midwest region, 3 is the South region and 4 is the West region.

Table 1.png

 

The pick function can be used to show the region name that is represented by the state code. This can be done by adding the measure below to the table.

measure.png

 

The pick function will assess the value of StateCode and based on that return a region.  With the measure added to the table, the region name can also be displayed as seen below.

Table 2.png

The pick function measure used in the table above is simpler than a nested if statement and is easy to read. It optimizes the table, returning results faster and using less resources to evaluate. Try it out.

Thanks,

Jennell