<?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 Calculating Previous Periods Invoiced Value in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Calculating-Previous-Periods-Invoiced-Value/m-p/689083#M1077885</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 would really appreciate some much needed help and advice on this. I know its basic and I've been reading a lot of discussion threads out there but I am still stuck. I will try and give as much information as I can but I really would be very grateful for some help on this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Firstly I had to convert my Financial PeriodCode - "PERIODDATE" in my script (loaded from a SQL Server database) because it was a text field showing only 14-01, 14-02 etc. I got QlikView to read it as a date value and to present in the format of "YY-MM" because that's how our financial period works and known as. I used the following to do this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I used this in my load script:&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Date(PERIODCODE, 'YY-MM') as PERIODDATE, after I converted the field in my SQL Select statement: convert(datetime2, '20'+[PERIODCODE]+'-01', 120) PERIODCODE,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, I have three columns in my straight table, first my dimension (By office) and second and third my expressions:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Expression 1 - Invoiced Current Period:&lt;/P&gt;&lt;P&gt;=SUM({&amp;lt;STATUS={'INVOICED'}&amp;gt;} VALUE)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Expression 2 - Invoice Previous Period:&lt;/P&gt;&lt;P&gt;SUM({&amp;lt;STATUS={'INVOICED'}, PERIODDATE={$(=Only(PERIODDATE)-1)}&amp;gt;} VALUE)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Exp1 works great and gives me back the correct value, but Exp2 only gives me a value of £0.00 everytime, but in the label, it does show that it's reading something but from some research I believe its displaying the year/month numeric value: SUM({STATUS={'INVOICED'}, PERIODDATE={41639}&amp;gt;} VALUE)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I change the load script to:&amp;nbsp; num(month(PERIODCODE)) AS PERIODDATE, it works and gives me the previous value but displays the PeriodCode as 1, 2, 3, 4 and so on for each month but with this I have to created a seperate list box so I can define the year and I need to just have one list box displaying each period as 14-07 and so on.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have seen that people are suggesting to use variables but I have tried this and it hasn't worked for me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I really hope this makes sense, if you have read this far, thank you so much for taking the time to read this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Richard&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 16 Jul 2014 15:22:33 GMT</pubDate>
    <dc:creator />
    <dc:date>2014-07-16T15:22:33Z</dc:date>
    <item>
      <title>Calculating Previous Periods Invoiced Value</title>
      <link>https://community.qlik.com/t5/QlikView/Calculating-Previous-Periods-Invoiced-Value/m-p/689083#M1077885</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 would really appreciate some much needed help and advice on this. I know its basic and I've been reading a lot of discussion threads out there but I am still stuck. I will try and give as much information as I can but I really would be very grateful for some help on this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Firstly I had to convert my Financial PeriodCode - "PERIODDATE" in my script (loaded from a SQL Server database) because it was a text field showing only 14-01, 14-02 etc. I got QlikView to read it as a date value and to present in the format of "YY-MM" because that's how our financial period works and known as. I used the following to do this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I used this in my load script:&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Date(PERIODCODE, 'YY-MM') as PERIODDATE, after I converted the field in my SQL Select statement: convert(datetime2, '20'+[PERIODCODE]+'-01', 120) PERIODCODE,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, I have three columns in my straight table, first my dimension (By office) and second and third my expressions:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Expression 1 - Invoiced Current Period:&lt;/P&gt;&lt;P&gt;=SUM({&amp;lt;STATUS={'INVOICED'}&amp;gt;} VALUE)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Expression 2 - Invoice Previous Period:&lt;/P&gt;&lt;P&gt;SUM({&amp;lt;STATUS={'INVOICED'}, PERIODDATE={$(=Only(PERIODDATE)-1)}&amp;gt;} VALUE)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Exp1 works great and gives me back the correct value, but Exp2 only gives me a value of £0.00 everytime, but in the label, it does show that it's reading something but from some research I believe its displaying the year/month numeric value: SUM({STATUS={'INVOICED'}, PERIODDATE={41639}&amp;gt;} VALUE)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I change the load script to:&amp;nbsp; num(month(PERIODCODE)) AS PERIODDATE, it works and gives me the previous value but displays the PeriodCode as 1, 2, 3, 4 and so on for each month but with this I have to created a seperate list box so I can define the year and I need to just have one list box displaying each period as 14-07 and so on.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have seen that people are suggesting to use variables but I have tried this and it hasn't worked for me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I really hope this makes sense, if you have read this far, thank you so much for taking the time to read this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Richard&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Jul 2014 15:22:33 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Calculating-Previous-Periods-Invoiced-Value/m-p/689083#M1077885</guid>
      <dc:creator />
      <dc:date>2014-07-16T15:22:33Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating Previous Periods Invoiced Value</title>
      <link>https://community.qlik.com/t5/QlikView/Calculating-Previous-Periods-Invoiced-Value/m-p/689084#M1077886</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So you have:&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;"&gt;Date(PERIODCODE, 'YY-MM') as PERIODDATE&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;Let's say we have the date to be 7/16/2014. It has the equivalent number value of 41836. Even though you change the format to '14-07', the number representation of the date stays the same (41836). Therefore in the set analysis, when you do only(PERIODDate)-1, it will return 41835. But it's not in the same format of YY-MM, so the set analysis won't work.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;I'd try this in script:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;date(MonthStart(&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;PERIODCODE&lt;/SPAN&gt;), 'YY-MM') as &lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;PERIODDATE&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;Then for your one expression, I would use:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;sum({&amp;lt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;STATUS={'INVOICED'},&lt;/SPAN&gt; &lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;PERIODDATE&lt;/SPAN&gt; = {"$(=date(addmonths(&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;PERIODDATE&lt;/SPAN&gt;, -1), 'YY-MM'))"}&amp;gt;}&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;VALUE&lt;/SPAN&gt;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;Here, addmonths will get the date with one month subtracted from the origial date. But then it will return the date in the format of the default (like M/D/YYYY). Then use the date format to make it go back to the YY-MM format.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;Please find attached.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;Hope this helps!&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Jul 2014 17:24:32 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Calculating-Previous-Periods-Invoiced-Value/m-p/689084#M1077886</guid>
      <dc:creator>jerem1234</dc:creator>
      <dc:date>2014-07-16T17:24:32Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating Previous Periods Invoiced Value</title>
      <link>https://community.qlik.com/t5/QlikView/Calculating-Previous-Periods-Invoiced-Value/m-p/689085#M1077887</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you very much for explaining this to me, it has help tremendously and has worked a treat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind Regards &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Jul 2014 10:04:00 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Calculating-Previous-Periods-Invoiced-Value/m-p/689085#M1077887</guid>
      <dc:creator />
      <dc:date>2014-07-17T10:04:00Z</dc:date>
    </item>
  </channel>
</rss>

