<?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 Is there an elegant formula for this? in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Is-there-an-elegant-formula-for-this/m-p/454399#M169539</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I want to track trends in usage over the last 12 months. I have an expression which gives me the total activity for each month, with company as the dimension. What I want to find out is how much is this month's usage over/under the 12 month average, but if the company didn't join us until, say, six months ago, I want the average to be six months, in other words: % change = (this month's usage)/(sum(current month to first month of usage)/(# of usage months))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, if a company joined a year ago, it would be (this month's usage)/(sum(past year)/12). If they joined in January (i.e. 5 months ago), it would be (this month's usage)/(sum(January to May)/5). But I don't have a 'join date', so all I can do is guess if ALL the months previous to, say, January, are zero, then the customer joined in January.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now, I know I can brute force this with a bunch of nested if's, e.g.YTDUsage= if(usage(Month-12)&amp;gt;0,if(usage(Month-11)&amp;gt;0,if(usage(month-10)..etc..,sum(Month-10 to This Month),sum(month -11 to This Month),sum(month-12 to this month))))))) (many closing parentheses required but..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;that look inelegant and a pain to maintain. Is there an elegant way of accomplishing the same thing?&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;Kevin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 13 May 2013 20:03:36 GMT</pubDate>
    <dc:creator />
    <dc:date>2013-05-13T20:03:36Z</dc:date>
    <item>
      <title>Is there an elegant formula for this?</title>
      <link>https://community.qlik.com/t5/QlikView/Is-there-an-elegant-formula-for-this/m-p/454399#M169539</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I want to track trends in usage over the last 12 months. I have an expression which gives me the total activity for each month, with company as the dimension. What I want to find out is how much is this month's usage over/under the 12 month average, but if the company didn't join us until, say, six months ago, I want the average to be six months, in other words: % change = (this month's usage)/(sum(current month to first month of usage)/(# of usage months))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, if a company joined a year ago, it would be (this month's usage)/(sum(past year)/12). If they joined in January (i.e. 5 months ago), it would be (this month's usage)/(sum(January to May)/5). But I don't have a 'join date', so all I can do is guess if ALL the months previous to, say, January, are zero, then the customer joined in January.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now, I know I can brute force this with a bunch of nested if's, e.g.YTDUsage= if(usage(Month-12)&amp;gt;0,if(usage(Month-11)&amp;gt;0,if(usage(month-10)..etc..,sum(Month-10 to This Month),sum(month -11 to This Month),sum(month-12 to this month))))))) (many closing parentheses required but..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;that look inelegant and a pain to maintain. Is there an elegant way of accomplishing the same thing?&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;Kevin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 May 2013 20:03:36 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Is-there-an-elegant-formula-for-this/m-p/454399#M169539</guid>
      <dc:creator />
      <dc:date>2013-05-13T20:03:36Z</dc:date>
    </item>
    <item>
      <title>Re: Is there an elegant formula for this?</title>
      <link>https://community.qlik.com/t5/QlikView/Is-there-an-elegant-formula-for-this/m-p/454400#M169540</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;sorry, the nested ifs would look like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;YTDUsage = if(usage(month-12)&amp;gt;0,sum(usage(month-12 to this month),if(usage(month-11)&amp;gt;0,sum(usage(month-11 to this month),etc, etc. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 May 2013 20:06:21 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Is-there-an-elegant-formula-for-this/m-p/454400#M169540</guid>
      <dc:creator />
      <dc:date>2013-05-13T20:06:21Z</dc:date>
    </item>
  </channel>
</rss>

