<?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: Cumulated sum (loops in expression?) in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Cumulated-sum-loops-in-expression/m-p/1235750#M24355</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Like I said, it would be difficult to give much suggestion before have a look at this. May be there is an easier way to do this without using loops (something like &lt;A href="https://community.qlik.com/people/marcus_sommer"&gt;marcus_sommer&lt;/A&gt;‌'s suggestion), but without seeing a sample it would be difficult to comment.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 21 Feb 2017 13:34:43 GMT</pubDate>
    <dc:creator>sunny_talwar</dc:creator>
    <dc:date>2017-02-21T13:34:43Z</dc:date>
    <item>
      <title>Cumulated sum (loops in expression?)</title>
      <link>https://community.qlik.com/t5/App-Development/Cumulated-sum-loops-in-expression/m-p/1235746#M24351</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So I'm wondering if its possible to do a loop within an expression in QlikSense.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've got income data across 2 years, and want to do YTD income comparisons - so if i'm in March 2017, for 2016, I need to add up Jan/Feb/March but ignore the rest of the year..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can do this with a lengthy set of IF statements: (vMonth &amp;amp; vYear are user controllable variables from the report)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;eg:&lt;/P&gt;&lt;P&gt;---------------------------------------------------------------------&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000080;"&gt;//January&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000080;"&gt;if($(vMonth)&amp;gt;= 1,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000080;"&gt;//In Month&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000080;"&gt;Sum(if(monthstart(cashbookdate) = Makedate($(vYear)-1,1)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000080;"&gt;&amp;nbsp; and (EffectiveDate &amp;lt;=&amp;nbsp; MonthEnd(MakeDate($(vYear)-1,1)) or (isnull(EffectiveDate) and year(cashbookdate) = $(vYear)-1))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000080;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; and TranType = 'New Business'&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000080;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ,&amp;nbsp;&amp;nbsp; (Commission_Calcd)))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000080;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000080;"&gt;+&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000080;"&gt;//Brought forward&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000080;"&gt;&amp;nbsp; Sum(if(cashbookdate &amp;lt; MakeDate($(vYear)-1, 1)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000080;"&gt;&amp;nbsp; and MonthStart(EffectiveDate) = MakeDate($(vYear)-1, 1)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000080;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; and TranType = 'New Business'&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000080;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ,&amp;nbsp;&amp;nbsp; (Commission_Calcd)))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000080;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000080;"&gt;,0)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000080;"&gt;+&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000080;"&gt;//February&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000080;"&gt;if($(vMonth)&amp;gt;= 2,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px; color: #000080;"&gt;//In Month&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000080;"&gt;Sum(if(monthstart(cashbookdate) = Makedate($(vYear)-1,2)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000080;"&gt;&amp;nbsp; and (EffectiveDate &amp;lt;=&amp;nbsp; MonthEnd(MakeDate($(vYear)-1,2)) or (isnull(EffectiveDate) and year(cashbookdate) = $(vYear)-1))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000080;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; and TranType = 'New Business'&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000080;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ,&amp;nbsp;&amp;nbsp; (Commission_Calcd)))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000080;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000080;"&gt;+&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000080;"&gt;//Brought forward&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000080;"&gt;&amp;nbsp; Sum(if(cashbookdate &amp;lt; MakeDate($(vYear)-1, 2)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000080;"&gt;&amp;nbsp; and MonthStart(EffectiveDate) = MakeDate($(vYear)-1, 2)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000080;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; and TranType = 'New Business'&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000080;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ,&amp;nbsp;&amp;nbsp; (Commission_Calcd)))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000080;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000080;"&gt;,0)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000080;"&gt;+&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000080;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000080;"&gt;//March&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;---------------------------------------------------------------------&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;//Continued for the rest of the months..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but this takes a very long time for Qlik to calculate - and also, when trying to do YOY % this means 2 lots of that code (current year / prior year) which doesnt actually fit in the allowed space in QlikSense as a formula.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was hoping to do something like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;---------------------------------------------------------------------&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000080;"&gt;Set i = 1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000080;"&gt;do while $(vMonth) &amp;gt;= i&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000080;"&gt;Sum(if(monthstart(cashbookdate) = Makedate($(vYear),i)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000080;"&gt;&amp;nbsp; and (EffectiveDate &amp;lt;=&amp;nbsp; MonthEnd(MakeDate($(vYear),i)) or (isnull(EffectiveDate) and year(cashbookdate) = $(vYear)))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000080;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; and TranType = 'New Business'&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000080;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ,&amp;nbsp;&amp;nbsp; (Commission_Calcd)))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000080;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000080;"&gt;+&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000080;"&gt;//Brought forward&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000080;"&gt;&amp;nbsp; Sum(if(cashbookdate &amp;lt; MakeDate($(vYear), i)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000080;"&gt;&amp;nbsp; and MonthStart(EffectiveDate) = MakeDate($(vYear), i)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000080;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; and TranType = 'New Business'&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000080;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ,&amp;nbsp;&amp;nbsp; (Commission_Calcd)))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000080;"&gt;Let i = i + 1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000080;"&gt;loop&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;---------------------------------------------------------------------&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but Sense doesnt seem to like loops in the expressions? At least, not how I've typed it there anyway.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does anyone know of any way I could add up the calculations above in as little code as possible to get away from the list of IF statements?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Alec&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 16 Nov 2024 10:03:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Cumulated-sum-loops-in-expression/m-p/1235746#M24351</guid>
      <dc:creator>abrown229</dc:creator>
      <dc:date>2024-11-16T10:03:41Z</dc:date>
    </item>
    <item>
      <title>Re: Cumulated sum (loops in expression?)</title>
      <link>https://community.qlik.com/t5/App-Development/Cumulated-sum-loops-in-expression/m-p/1235747#M24352</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You might be able to use ValueLoop here, but difficult to give an exact expression without testing it out.&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.qlik.com/docs/DOC-9013"&gt;Missing Manual - ValueLoop() &amp;amp;amp; ValueList()&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Feb 2017 12:19:22 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Cumulated-sum-loops-in-expression/m-p/1235747#M24352</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2017-02-21T12:19:22Z</dc:date>
    </item>
    <item>
      <title>Re: Cumulated sum (loops in expression?)</title>
      <link>https://community.qlik.com/t5/App-Development/Cumulated-sum-loops-in-expression/m-p/1235748#M24353</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the reply Sunny, this looks promising - can I use multiple ValueLoops like below?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Sum(if($(vMonth)&amp;gt;= valueloop(1,12)),&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;//In Month&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Sum(if(monthstart(cashbookdate) = Makedate($(vYear),valueloop(1,12))&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp; and (EffectiveDate &amp;lt;=&amp;nbsp; MonthEnd(MakeDate($(vYear),valueloop(1,12))) or (isnull(EffectiveDate) and year(cashbookdate) = $(vYear)))&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; and TranType = 'New Business'&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ,&amp;nbsp;&amp;nbsp; (Commission_Calcd)))&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;+&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;//Brought forward&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp; Sum(if(cashbookdate &amp;lt; MakeDate($(vYear), valueloop(1,12))&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp; and MonthStart(EffectiveDate) = MakeDate($(vYear), valueloop(1,12)&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; and TranType = 'New Business'&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ,&amp;nbsp;&amp;nbsp; (Commission_Calcd)))))&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The expression box says its fine but it returns nothing..&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Feb 2017 13:27:29 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Cumulated-sum-loops-in-expression/m-p/1235748#M24353</guid>
      <dc:creator>abrown229</dc:creator>
      <dc:date>2017-02-21T13:27:29Z</dc:date>
    </item>
    <item>
      <title>Re: Cumulated sum (loops in expression?)</title>
      <link>https://community.qlik.com/t5/App-Development/Cumulated-sum-loops-in-expression/m-p/1235749#M24354</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If your LYTD/YTD period is fix to today it's quite common to create flags for them within a master-calendar. Are they instead variable you will need a different approach by creating a PeriodID within the sorted master-calendar, for example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;autonumber(Year &amp;amp; '|' &amp;amp; Month) as PeriodID&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and then you could use this PeriodID within a set analysis condition like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sum({&amp;lt; PeriodID = {"&amp;gt;=$(=max(PeriodID)-12)&amp;lt;=$(=max(PeriodID))"}&amp;gt;} Value)&lt;/P&gt;&lt;P&gt;sum({&amp;lt; PeriodID = {"&amp;gt;=$(=max(PeriodID)-24)&amp;lt;=$(=max(PeriodID)-12)"}&amp;gt;} Value&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;More to master-calendars and various calculations with periods could you find here: &lt;A href="https://community.qlik.com/docs/DOC-8843"&gt;How to use - Master-Calendar and Date-Values&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- Marcus&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Feb 2017 13:28:16 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Cumulated-sum-loops-in-expression/m-p/1235749#M24354</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2017-02-21T13:28:16Z</dc:date>
    </item>
    <item>
      <title>Re: Cumulated sum (loops in expression?)</title>
      <link>https://community.qlik.com/t5/App-Development/Cumulated-sum-loops-in-expression/m-p/1235750#M24355</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Like I said, it would be difficult to give much suggestion before have a look at this. May be there is an easier way to do this without using loops (something like &lt;A href="https://community.qlik.com/people/marcus_sommer"&gt;marcus_sommer&lt;/A&gt;‌'s suggestion), but without seeing a sample it would be difficult to comment.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Feb 2017 13:34:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Cumulated-sum-loops-in-expression/m-p/1235750#M24355</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2017-02-21T13:34:43Z</dc:date>
    </item>
  </channel>
</rss>

