Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

sumitsahu009
Not applicable

Using variable in SET analysis

Hi all,

I have a very basic doubt on using variable in SET analysis in Qliksense.

In table i have have three columns, as shown below:

 

eventdatemonthamount
31-05-20162016_52
31-05-20162016_53
31-05-20162016_516
31-05-20162016_521
31-05-20162016_522
31-05-20162016_525
31-05-20162016_534
31-05-20162016_538
31-05-20162016_548

I want to calculate sum of amount for last month (2016_5).

Now for this,

I am creating a variable which is year_month.

In script i created this variable as:

set vmonth_1=(year(today()))&'_'&(month(today())-1);

Now, i am writing set analysis for this:

sum({<month={'$(=vmonth_1)'}>} amount)

but this statement doesn't seem to work and result shows as "-". I am really confused with this, appreciated if anyone can help me on this.

Thanks

1 Solution

Accepted Solutions
swuehl
Not applicable

Re: Using variable in SET analysis

Try

LET vmonth_1=(year(today()))&'_'&(month(today())-1);

Now your variable should hold  2016_5

Then:

sum({<month={'$(vmonth_1)'}>} amount)



edit: Please note that your variable will probably not create the correct value in January.

2 Replies
swuehl
Not applicable

Re: Using variable in SET analysis

Try

LET vmonth_1=(year(today()))&'_'&(month(today())-1);

Now your variable should hold  2016_5

Then:

sum({<month={'$(vmonth_1)'}>} amount)



edit: Please note that your variable will probably not create the correct value in January.

sumitsahu009
Not applicable

Re: Using variable in SET analysis

oh yes!

Thanks!