Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

abhi251983
New Contributor II

Using variable value in Set Expression

Hi,

I'm trying to store one dynamic expression in a variable and then trying to utilize in the expression.

Variable:

vCurrent_Quarter = 1

vCurrent_Year = 2015

vNext_Quarter = If($(vCurrent_Quarter)=4,'Q'& 1 & ' ' & Right(($(vCurrent_year)+1),2),'Q'&($(vCurrent_Quarter)+1) & ' ' & Right($(vCurrent_year),2))

Expression: Sum({$<FQY = {'$(=vNext_Quarter)'}>} Amount)

Basically the FQY values are Q1 15, Q2 15 etc. and based on the Current year variable value, I want to produce the next quarter FQY value. For ex. if Current Quarter variable value is 1 then the FQY value should be Q2 15.

Thanks in advance for your help!!!

1 Solution

Accepted Solutions
gmoraleswit
Contributor II

Re: Re: Using variable value in Set Expression

see attach

6 Replies
Not applicable

Re: Using variable value in Set Expression

Simply add the new field called "Next Quarter"  to the Calendar table & use that field in Set Analysis.

gmoraleswit
Contributor II

Re: Using variable value in Set Expression

I think you are missing another dollar sign expansion, try this:

Sum({$<FQY = {'$(=$(vNext_Quarter))'}>} Amount)

abhi251983
New Contributor II

Re: Using variable value in Set Expression

This can be done but I don't want to manually do that stuff as today the requirement is to get the next quarter but what if when the requirement changes to have the next 2 quarter instead of next quarter.

Therefore, I want to achieve this behavior dynamically.

abhi251983
New Contributor II

Re: Using variable value in Set Expression

Thanks Gabriela, but that is dollar sign is optional. Even if you wouldn't add the $ sign, qv assumes that you want to add $ and therefore a default behavior.

gmoraleswit
Contributor II

Re: Re: Using variable value in Set Expression

see attach

abhi251983
New Contributor II

Re: Re: Using variable value in Set Expression

Thanks so much Gabriela. It worked perfectly.

Community Browser