Skip to main content

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
Welcome to Qlik Community! Check out our new navigation! FIND OUT MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
bekahbeets
Creator
Creator

set analysis formula comparable to sql's 'in' command?

I have set a variable equal to a field selection like so:

vSelectedYear = GetFieldSelections(YearField)

sometimes vSelectedYear will hold multiple values (2017, 2016, etc)

The set analysis formula looks like such right now:

sum(  {<YearField = {"$(=$(vSelectedYear))"} >}  [$(vType)])

this works fine if only one year is selected, but I would like it to work when vSelectedYear holds multiple years.

In Sql it would look like:

Select sum(vType)

from table

where YearField in (vSelectedYear)

1 Solution

Accepted Solutions
swuehl
MVP
MVP

It should work if you remove the double quotes (assuming integer values for years):

sum(  {<YearField = {$(=$(vSelectedYear))} >}  [$(vType)])


Or use the p() function or the scope operator to directly acces field values selected or possible:

sum(  {<YearField = $::YearField >}  [$(vType)])


sum(  {<YearField = p(YearField) >}  [$(vType)])


(though latter set expression should not make a difference to just the pure aggregation?)

View solution in original post

2 Replies
swuehl
MVP
MVP

It should work if you remove the double quotes (assuming integer values for years):

sum(  {<YearField = {$(=$(vSelectedYear))} >}  [$(vType)])


Or use the p() function or the scope operator to directly acces field values selected or possible:

sum(  {<YearField = $::YearField >}  [$(vType)])


sum(  {<YearField = p(YearField) >}  [$(vType)])


(though latter set expression should not make a difference to just the pure aggregation?)

bekahbeets
Creator
Creator
Author

Thanks! Removing the quotes did the trick!