<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Problem with variable in set expression in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Problem-with-variable-in-set-expression/m-p/115473#M17784</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This alternate may also work for you -&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 13 Sep 2018 19:00:18 GMT</pubDate>
    <dc:creator>neelamsaroha157</dc:creator>
    <dc:date>2018-09-13T19:00:18Z</dc:date>
    <item>
      <title>Problem with variable in set expression</title>
      <link>https://community.qlik.com/t5/QlikView/Problem-with-variable-in-set-expression/m-p/115464#M17775</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a problem with a SET analysis variable, it won't evaluate through more than the last year.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have data like:&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" style="border: 1px solid rgb(0, 0, 0); width: 100%;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Year&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Month&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Data&lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;2013&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;Jan&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;25000&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;2013&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;Feb&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;37000&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;...&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;...&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;..&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;2013&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;Dec&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;42000&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;...&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;...&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;...&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;2018&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;Sep&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;102500&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;.. and so on through all months up until today.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;SPAN style="font-size: 10pt;"&gt;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. &lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN style="font-size: 10pt;"&gt;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.&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN style="font-size: 10pt;"&gt;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.&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;I have a field in my script (&lt;SPAN style="font-size: 13.3333px;"&gt;MonthVariable) &lt;/SPAN&gt;that puts this data on every year-month: jan-13, feb-13, mar-13 and so on..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This script will output my desired month/year data:&lt;/P&gt;&lt;P&gt;Date(Max(MonthVariable),'MMM-YY') - Let's call it Monthlookup&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BUT:&lt;/P&gt;&lt;P&gt;When I use this script to sum the results: &lt;SPAN style="font-size: 13.3333px;"&gt;Sum({$&amp;lt;MonthVariable={"$(=Date(Max(MonthVariable),'MMM-YY'))"}&amp;gt;} Data)&lt;/SPAN&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I get this output:&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" style="border: 1px solid rgb(0, 0, 0); width: 100%;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Year&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;Monthlookup&lt;/SPAN&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Sum of data&lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;2013&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;dec-13&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;2014&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;dec-14&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;2015&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;dec-15&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;2016&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;dec-16&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;2017&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;dec-17&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;2018&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;sep-18&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;102500&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It works as desired when I choose months, but why doesn't it evaluate all the years?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Sep 2018 09:55:19 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Problem-with-variable-in-set-expression/m-p/115464#M17775</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-09-11T09:55:19Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with variable in set expression</title>
      <link>https://community.qlik.com/t5/QlikView/Problem-with-variable-in-set-expression/m-p/115465#M17776</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, Can you share the sample data with required output. It would be easier to see which part is not working.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Sep 2018 20:31:28 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Problem-with-variable-in-set-expression/m-p/115465#M17776</guid>
      <dc:creator>neelamsaroha157</dc:creator>
      <dc:date>2018-09-11T20:31:28Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with variable in set expression</title>
      <link>https://community.qlik.com/t5/QlikView/Problem-with-variable-in-set-expression/m-p/115466#M17777</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You cannot use Set Analysis for this case.&amp;nbsp; The set expression is evaluated only once per chart, not row by row. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Sep 2018 22:10:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Problem-with-variable-in-set-expression/m-p/115466#M17777</guid>
      <dc:creator>rwunderlich</dc:creator>
      <dc:date>2018-09-11T22:10:51Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with variable in set expression</title>
      <link>https://community.qlik.com/t5/QlikView/Problem-with-variable-in-set-expression/m-p/115467#M17778</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Rob, do you have any suggestion how to solve the problem in another way?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Sep 2018 06:48:49 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Problem-with-variable-in-set-expression/m-p/115467#M17778</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-09-12T06:48:49Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with variable in set expression</title>
      <link>https://community.qlik.com/t5/QlikView/Problem-with-variable-in-set-expression/m-p/115468#M17779</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;try to do this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13.3333px;"&gt;aggr(Sum({$&amp;lt;MonthVariable={"$(=Date(Max(MonthVariable),'MMM-YY'))"}&amp;gt;} Data), Year) or&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-size: 13.3333px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;sum(aggr(Sum({$&amp;lt;MonthVariable={"$(=Date(Max(MonthVariable),'MMM-YY'))"}&amp;gt;} Data), Year) )&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13.3333px;"&gt;it's horrible but it may runs.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Sep 2018 15:22:47 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Problem-with-variable-in-set-expression/m-p/115468#M17779</guid>
      <dc:creator>captain89</dc:creator>
      <dc:date>2018-09-12T15:22:47Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with variable in set expression</title>
      <link>https://community.qlik.com/t5/QlikView/Problem-with-variable-in-set-expression/m-p/115469#M17780</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;sum(if(num(&lt;SPAN style="color: #3d3d3d; font-size: 13px;"&gt;MonthVariable&lt;/SPAN&gt;)=aggr(NODISTINCT Max(&lt;SPAN style="color: #3d3d3d; font-size: 13px;"&gt;MonthVariable&lt;/SPAN&gt;),Year), Data))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-Rob&lt;/P&gt;&lt;P&gt;&lt;A class="jive-link-external-small" href="http://masterssummit.com" rel="nofollow" target="_blank"&gt;http://masterssummit.com&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="jive-link-external-small" href="http://qlikviewcookbook.com" rel="nofollow" target="_blank"&gt;http://qlikviewcookbook.com&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="jive-link-external-small" href="http://www.easyqlik.com" rel="nofollow" target="_blank"&gt;http://www.easyqlik.com&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Sep 2018 17:09:14 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Problem-with-variable-in-set-expression/m-p/115469#M17780</guid>
      <dc:creator>rwunderlich</dc:creator>
      <dc:date>2018-09-12T17:09:14Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with variable in set expression</title>
      <link>https://community.qlik.com/t5/QlikView/Problem-with-variable-in-set-expression/m-p/115470#M17781</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry, I think I was unclear of the results I was looking for. I want to sum only the last month, not the entire years total.So let's say I have 97500 customers in dec-17 and &lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;102500 customers in aug-2018, thats the result I'm looking for. (I have data for each month, but I'm only interested in the customers at the end of the year).&lt;BR /&gt;&lt;/SPAN&gt;Your suggestion works fine Rob, although I get the totals for each year.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Sep 2018 07:07:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Problem-with-variable-in-set-expression/m-p/115470#M17781</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-09-13T07:07:51Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with variable in set expression</title>
      <link>https://community.qlik.com/t5/QlikView/Problem-with-variable-in-set-expression/m-p/115471#M17782</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'll get the desidered result with Rob's suggestion.&lt;/P&gt;&lt;P&gt;I suggest:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;create a field in script with yearmonth in number &lt;/P&gt;&lt;P&gt;such as :&lt;/P&gt;&lt;P&gt;load *,&lt;/P&gt;&lt;P&gt;year(date)*100+month(date)*1 as YearMonthNum,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;then take Rob's suggestion:&lt;/P&gt;&lt;P&gt;sum(if(&lt;SPAN style="font-size: 13.3333px;"&gt;YearMonthNum&lt;/SPAN&gt;=aggr(NODISTINCT Max(&lt;SPAN style="font-size: 13.3333px;"&gt;YearMonthNum&lt;/SPAN&gt;),Year), Data)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Sep 2018 15:32:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Problem-with-variable-in-set-expression/m-p/115471#M17782</guid>
      <dc:creator>captain89</dc:creator>
      <dc:date>2018-09-13T15:32:42Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with variable in set expression</title>
      <link>https://community.qlik.com/t5/QlikView/Problem-with-variable-in-set-expression/m-p/115472#M17783</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My solution calculates data only for the ;last month -- using my test data.&amp;nbsp; So perhaps there is an issue in your data or a misunderstanding here. Can you post a sample qvw?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Sep 2018 18:43:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Problem-with-variable-in-set-expression/m-p/115472#M17783</guid>
      <dc:creator>rwunderlich</dc:creator>
      <dc:date>2018-09-13T18:43:43Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with variable in set expression</title>
      <link>https://community.qlik.com/t5/QlikView/Problem-with-variable-in-set-expression/m-p/115473#M17784</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This alternate may also work for you -&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Sep 2018 19:00:18 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Problem-with-variable-in-set-expression/m-p/115473#M17784</guid>
      <dc:creator>neelamsaroha157</dc:creator>
      <dc:date>2018-09-13T19:00:18Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with variable in set expression</title>
      <link>https://community.qlik.com/t5/QlikView/Problem-with-variable-in-set-expression/m-p/115474#M17785</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;After playing around a little with your script I realized i didn't have to be that advanced.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have another field "MonthID" i.e: (201809), in the same table as Data, which always contains the last month of data.&lt;/P&gt;&lt;P&gt;I made a script like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Max(Aggr(Sum(CustCounter),MonthID))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So much fuss when the answer was quite simple. Hadn't used the Aggr-function before though.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot Rob, Matteo and Neelam for looking into this&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Sep 2018 10:14:14 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Problem-with-variable-in-set-expression/m-p/115474#M17785</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-09-14T10:14:14Z</dc:date>
    </item>
  </channel>
</rss>

