<?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 Problem with set analysis in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Problem-with-set-analysis/m-p/81007#M13314</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am fairly new to the set analysis method. And i am trying to replace some heavy if expressions with set analysis to increase the performance. Now i have a table with dimension "Company" consisting of ten companies.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the expression I am trying to achieve this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sum({$&amp;lt;isoweek = {"&amp;gt;$(=WeekStart(Max_Week,-4))"}&amp;gt;} Sales)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;so a sum of sales for the last 4 weeks counting back from "Max_Week".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The problem lies with the field "&lt;SPAN style="font-size: 13.3333px;"&gt;Max_Week". The set analysis expression works fine as long as "Max_Week" is the same for all the companies (for example all "2018/12"). &lt;/SPAN&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;But when one company has a different value for MaxWeek the expression turns out empty.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;I'm guessing i need to integrate AGGR and/or ONLY into the expression or something, but i haven't been able to work it out.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;Your help would be greatly appreciated.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;Best regards,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;Peter&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 23 Mar 2018 14:16:16 GMT</pubDate>
    <dc:creator>pepe2209</dc:creator>
    <dc:date>2018-03-23T14:16:16Z</dc:date>
    <item>
      <title>Problem with set analysis</title>
      <link>https://community.qlik.com/t5/QlikView/Problem-with-set-analysis/m-p/81007#M13314</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am fairly new to the set analysis method. And i am trying to replace some heavy if expressions with set analysis to increase the performance. Now i have a table with dimension "Company" consisting of ten companies.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the expression I am trying to achieve this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sum({$&amp;lt;isoweek = {"&amp;gt;$(=WeekStart(Max_Week,-4))"}&amp;gt;} Sales)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;so a sum of sales for the last 4 weeks counting back from "Max_Week".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The problem lies with the field "&lt;SPAN style="font-size: 13.3333px;"&gt;Max_Week". The set analysis expression works fine as long as "Max_Week" is the same for all the companies (for example all "2018/12"). &lt;/SPAN&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;But when one company has a different value for MaxWeek the expression turns out empty.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;I'm guessing i need to integrate AGGR and/or ONLY into the expression or something, but i haven't been able to work it out.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;Your help would be greatly appreciated.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;Best regards,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;Peter&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Mar 2018 14:16:16 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Problem-with-set-analysis/m-p/81007#M13314</guid>
      <dc:creator>pepe2209</dc:creator>
      <dc:date>2018-03-23T14:16:16Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with set analysis</title>
      <link>https://community.qlik.com/t5/QlikView/Problem-with-set-analysis/m-p/81008#M13315</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is Max_Week a variable or is that a field calculated in the script?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Mar 2018 14:26:02 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Problem-with-set-analysis/m-p/81008#M13315</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2018-03-23T14:26:02Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with set analysis</title>
      <link>https://community.qlik.com/t5/QlikView/Problem-with-set-analysis/m-p/81009#M13316</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It is a field calculated in the script&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Mar 2018 14:43:46 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Problem-with-set-analysis/m-p/81009#M13316</guid>
      <dc:creator>pepe2209</dc:creator>
      <dc:date>2018-03-23T14:43:46Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with set analysis</title>
      <link>https://community.qlik.com/t5/QlikView/Problem-with-set-analysis/m-p/81010#M13317</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;May be try this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Sum(Aggr(If(isoweek &amp;gt; WeekStart(Max_Week,-4), Sales), Company, isoweek))&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Mar 2018 14:46:49 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Problem-with-set-analysis/m-p/81010#M13317</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2018-03-23T14:46:49Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with set analysis</title>
      <link>https://community.qlik.com/t5/QlikView/Problem-with-set-analysis/m-p/81011#M13318</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for your reply.&lt;/P&gt;&lt;P&gt;This expression does work. But now you are using an if statement and no set analysis. The goal is to get a better performance in calcultation time. The original expression i had was:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;Sum(If(isoweek &amp;gt; WeekStart(Max_Week,-4), Sales)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;BR /&gt;&lt;/STRONG&gt;You gave me this expression. &lt;STRONG style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;BR /&gt;&lt;STRONG style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;Sum(Aggr(If(isoweek &amp;gt; WeekStart(Max_Week,-4), Sales), Company, isoweek))&lt;/STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Does your version have a better performance?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Mar 2018 15:31:03 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Problem-with-set-analysis/m-p/81011#M13318</guid>
      <dc:creator>pepe2209</dc:creator>
      <dc:date>2018-03-23T15:31:03Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with set analysis</title>
      <link>https://community.qlik.com/t5/QlikView/Problem-with-set-analysis/m-p/81012#M13319</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;No, it won't... the problem is that each company can have a differnt Max_week which won't really work within set analysis.... what you can do is to calculate a flag in the script&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;LOAD ...,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If(&lt;/STRONG&gt;&lt;STRONG style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;isoweek &amp;gt; WeekStart(Max_Week,-4), 1, 0) as Flag&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and then this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Sum({&amp;lt;Flag = {1}&amp;gt;}Sales)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Sum(Sales * Flag)&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Mar 2018 15:35:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Problem-with-set-analysis/m-p/81012#M13319</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2018-03-23T15:35:04Z</dc:date>
    </item>
  </channel>
</rss>

