Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
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
MVP
MVP

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.

View solution in original post

2 Replies
swuehl
MVP
MVP

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.

Anonymous
Not applicable
Author

oh yes!

Thanks!