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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

selection year?

Hi

i have like

load * inline

year,sales

2000,100

2001,200

2002,300

2003,400

2004,500

2005,600

2006,700

2007,800

];

my req is     1)     if click on year 2001 then  i want to see the sales for     20001,2002,2003? (from current selection to 3 yers )

                   2)     if click on year 2001 then  i want to see the sales for     20002,2003,2004?(excluding current selections)

Labels (1)
1 Solution

Accepted Solutions
its_anandrjs
Champion III
Champion III

Hi,

You can try this with the GetFieldSelections() function for get the selection values and try like

1. =sum({<year = {'>=$(=GetFieldSelections(year)) <=$(=GetFieldSelections(year)+2)'}>}sales)

2. =sum({<year = {'>=$(=GetFieldSelections(year)+1) <=$(=GetFieldSelections(year)+3)'}>}sales)

getselection.png

Regards

Anand

View solution in original post

3 Replies
maxgro
MVP
MVP

for this

sum({$ <year={">=$(=max(year))<=$(=max(year)+2)"}>} sales)

sum({$ <year={">=$(=max(year)+1)<=$(=max(year)+3)"}>} sales)

1.png

its_anandrjs
Champion III
Champion III

Hi,

You can try this with the GetFieldSelections() function for get the selection values and try like

1. =sum({<year = {'>=$(=GetFieldSelections(year)) <=$(=GetFieldSelections(year)+2)'}>}sales)

2. =sum({<year = {'>=$(=GetFieldSelections(year)+1) <=$(=GetFieldSelections(year)+3)'}>}sales)

getselection.png

Regards

Anand

its_anandrjs
Champion III
Champion III

Hi,

If you use this expression for both query will be better

1. =if( GetSelectedCount(year) = 0,Sum(sales),sum({<year = {'>=$(=GetFieldSelections(year)) <=$(=GetFieldSelections(year)+2)'}>}sales))

2. =if(GetSelectedCount(year) = 0,Sum(sales),sum({<year = {'>=$(=GetFieldSelections(year)+1) <=$(=GetFieldSelections(year)+3)'}>}sales))

Regards

Anand