Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Problem with variable in set expression

Hi,

I have a problem with a SET analysis variable, it won't evaluate through more than the last year.

I have data like:

YearMonthData
2013Jan25000
2013Feb37000
........
2013Dec42000
.........
2018Sep102500

.. and so on through all months up until today.


  • The first thing I want to evaluate is, if there is 12 months in the year, sum Data for that year in december. So, the sum of 2013 should be 42000.
  • Second, if there's no twelfth month, sum Data for the last month in that year, in this case it should sum to 102500 for 2018.
  • Third, if I make a selection in the month dimension, let's say I pick April. The sum of Data should be for april for all years.

I have a field in my script (MonthVariable) that puts this data on every year-month: jan-13, feb-13, mar-13 and so on..

This script will output my desired month/year data:

Date(Max(MonthVariable),'MMM-YY') - Let's call it Monthlookup

BUT:

When I use this script to sum the results: Sum({$<MonthVariable={"$(=Date(Max(MonthVariable),'MMM-YY'))"}>} Data)

I get this output:

YearMonthlookupSum of data
2013dec-130
2014dec-140
2015dec-150
2016dec-160
2017dec-170
2018sep-18102500

It works as desired when I choose months, but why doesn't it evaluate all the years?

10 Replies
Anonymous
Not applicable
Author

After playing around a little with your script I realized i didn't have to be that advanced.

I have another field "MonthID" i.e: (201809), in the same table as Data, which always contains the last month of data.

I made a script like this:

Max(Aggr(Sum(CustCounter),MonthID))

So much fuss when the answer was quite simple. Hadn't used the Aggr-function before though.

Thanks a lot Rob, Matteo and Neelam for looking into this