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: 
maasool
Contributor III
Contributor III

Variable with multiple values

I would like to assign variable YTD values from 1 to 10. Goal is to use this variable in set expression, so it can have values 1 and 2 and 3 and so on. How to do it in code?

I tried something like this, but doesn't seem to work:

YTD='{'&1&2&3&4&5&6&7&8&9&10&'}'

Best
maasool

1 Solution

Accepted Solutions
tresesco
MVP
MVP

In set analysis, you could also use '<=' or '>=' instead of mentioning all individual numbers. Hence, you may try like:

=Sum({<MonthNum={"<=$(=vMaxMonth)"}>}Sales)

where your variable vMaxMonth would hold the maximum month number you want to sum the amount upto.

View solution in original post

6 Replies
lironbaram
Partner - Master III
Partner - Master III

hi

why do you need more than one value in your variable 

if the current value is 10 than your set expression can be {<something <= YOURVARIABLE >}

maasool
Contributor III
Contributor III
Author

Hi!

To calculate YTD sales. Instead of updating master items, I could update only one variable defined in data load.

For example, in March, I would like to include sales for months 1,2,3. For October, I would like to include months 1,2,3,4,5,6,7,8,9 and 10.

Best
maasool

tresesco
MVP
MVP

In set analysis, you could also use '<=' or '>=' instead of mentioning all individual numbers. Hence, you may try like:

=Sum({<MonthNum={"<=$(=vMaxMonth)"}>}Sales)

where your variable vMaxMonth would hold the maximum month number you want to sum the amount upto.

maasool
Contributor III
Contributor III
Author

Thanks! 

124rooski
Partner - Creator
Partner - Creator

what would be the case if I wanted to do something similar but with actual dimension values vs numbers? For example - instead of sum of sales for months 1-10 what about sum of sales for the given product 'A','B','C', etc.

PrashantSangle

Post as new question with sample data and required output

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂