Qlik Community

Ask a Question

App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

Announcements
April 22, 2PM EST: Learn about GeoOperations in Qlik Sense SaaS READ MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
h2k18
Contributor II
Contributor II

Passing variable - Set Analysis

Hi,

I have created the following variable to be utilized in the set analysis calculation:

vCurrQTR = 2018Q4 (User selected)

Variable Name: vTestQTR

 =if(right(vCurrQTR,2) = 'Q4',
chr(39)&left(vCurrQTR,4)&''&'Q1'&chr(39)&chr(44)&
chr(39)&left(vCurrQTR,4)&''&'Q2'&chr(39)&chr(44)&
chr(39)&left(vCurrQTR,4)&''&'Q3'&chr(39)&chr(44)&
chr(39)&left(vCurrQTR,4)&''&'Q4')&chr(39)

If we evaluate the above variable (=vTestQTR) in Text & image object it will yield the following result: '2018Q1','2018Q2','2018Q3','2018Q4'

Currently:
sum({<PERIOD_TYPE = {'Q'},RETURN_TYPE = {'S'},PERIOD = {'2018Q1','2018Q2','2018Q3','2018Q4'}>}Return) gives the correct result.

Now using variable would like to replace the above highlighted condition and get the same result. Unfortunately the variable is not working as expected inside the set analysis expression. Can you help with the correct syntax?
sum({<PERIOD_TYPE = {'Q'},RETURN_TYPE = {'S'},PERIOD = {'variable'}>}Return)

Thanks.

Labels (2)
1 Solution

Accepted Solutions
sunny_talwar

Try this

if(RETURN_TYPE = 'R', Sum({<PERIOD = {$(=$(vTestQTR))}, PERIOD_TYPE = {'Q'}, RETURN_TYPE = {'R'}>} RETURN),
	if(RETURN_TYPE = 'S', Sum({<PERIOD = {$(=$(vTestQTR))}, PERIOD_TYPE = {'Q'}, RETURN_TYPE = {'S'}>} RETURN),
    	if(RETURN_TYPE = 'T', Sum({<PERIOD = {$(=$(vTestQTR))}, PERIOD_TYPE = {'Q'},RETURN_TYPE = {'T'}>} RETURN)
        )))

View solution in original post

5 Replies
sunny_talwar

Try one of these two options

Sum({<PERIOD_TYPE = {'Q'},RETURN_TYPE = {'S'},PERIOD = {"$(vTestQTR)"}>} Return)

Or

Sum({<PERIOD_TYPE = {'Q'},RETURN_TYPE = {'S'},PERIOD = {"$(=$(vTestQTR))"}>} Return)

 

h2k18
Contributor II
Contributor II
Author

Thanks for the response. When i tried them its gives me no result.

sunny_talwar

Would you be able to share a sample where we can see the issue?

h2k18
Contributor II
Contributor II
Author

Sure. The sample file is attached.

sunny_talwar

Try this

if(RETURN_TYPE = 'R', Sum({<PERIOD = {$(=$(vTestQTR))}, PERIOD_TYPE = {'Q'}, RETURN_TYPE = {'R'}>} RETURN),
	if(RETURN_TYPE = 'S', Sum({<PERIOD = {$(=$(vTestQTR))}, PERIOD_TYPE = {'Q'}, RETURN_TYPE = {'S'}>} RETURN),
    	if(RETURN_TYPE = 'T', Sum({<PERIOD = {$(=$(vTestQTR))}, PERIOD_TYPE = {'Q'},RETURN_TYPE = {'T'}>} RETURN)
        )))

View solution in original post