<?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 Calculation with Month's Last Day in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Calculation-with-Month-s-Last-Day/m-p/204350#M1209064</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Day(Month) gives you the day number in the month, so 22, or 31, or ...&lt;/P&gt;&lt;P&gt;day( '1971-10-30' ) returns 30.&lt;/P&gt;&lt;P&gt;When you subtract the days, you don't automatically receive the right number of days, since there could be a month transition or a period of several months.&lt;/P&gt;&lt;P&gt;What you need it to subtract the day numbers from eachother is the actual number that represents the date. Use Num(Date) to get that number.&lt;/P&gt;&lt;P&gt;Num(Day(ENDMONTH)) - Num(Day(Received))&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 20 Nov 2009 23:07:00 GMT</pubDate>
    <dc:creator />
    <dc:date>2009-11-20T23:07:00Z</dc:date>
    <item>
      <title>Calculation with Month's Last Day</title>
      <link>https://community.qlik.com/t5/QlikView/Calculation-with-Month-s-Last-Day/m-p/204349#M1209063</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, first post here, so forgive the newbie question:)&lt;/P&gt;&lt;P&gt;I'm using QVPE to evaluate it's possible uses for my company, I'm trying to reproduce the functionalities of a quite complex xls with qlikview in order to produce something more usable and appealing for one of our customers.&lt;/P&gt;&lt;P&gt;Unfourtunately, I'm stuck with a "stupid problem" atm&lt;/P&gt;&lt;P&gt;I have a serie of rows, each with 3 different dates (Recived, Closed, Limit)&lt;/P&gt;&lt;P&gt;I want to show some statistics based on those dates and grouped by the different months&lt;/P&gt;&lt;P&gt;I've loaded a calendar from an excel table with the script:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOAD DATA,&lt;/P&gt;&lt;P&gt;month(DATA) as MONTH,&lt;/P&gt;&lt;P&gt;MonthEnd(Date([DATA])) as ENDMONTH&lt;/P&gt;&lt;P&gt;FROM&lt;/P&gt;&lt;P&gt;Calendar.xls&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In qlikview, I've a pivot table with MONTH as dimension, and then the various expression, like:&lt;/P&gt;&lt;P&gt;MONTH-- stat-1--stat2--&lt;/P&gt;&lt;P&gt;jan&lt;/P&gt;&lt;P&gt;feb&lt;/P&gt;&lt;P&gt;mar&lt;/P&gt;&lt;P&gt;One expression, which I know works fine is:&lt;/P&gt;&lt;P&gt;TEXTCOUNT (DISTINCT IF (MONTH(Closed) &amp;gt; MONTH AND MONTH(Received) &amp;lt;= MONTH,ID)) + TEXTCOUNT (DISTINCT IF (ISNULL(Closed) &amp;lt;&amp;gt; 0 AND MONTH(Received) &amp;lt;= MONTH,ID))&lt;/P&gt;&lt;P&gt;which returns the number of "non closed" for each of the months shown&lt;/P&gt;&lt;P&gt;Now, I want to show the average "age" (in days) for the "non closed" for each months&lt;/P&gt;&lt;P&gt;I've tried many ways but none worked and I'm a little lost now as I can't see the mistake:&lt;/P&gt;&lt;P&gt;avg( distinct IF ((MONTH(Closed)&amp;gt;MONTH or ISNULL(Closed) &amp;lt;&amp;gt;0 ) AND MONTH(Received)&amp;lt;=MONTH, DAY(ENDMONTH)-DAY(Received)))&lt;/P&gt;&lt;P&gt;I know that what isn't working is DAY(ENDMONTH)-DAY(Received), but I really can't see why...&lt;/P&gt;&lt;P&gt;I someone can point me in the right direction it would be really appreciated &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;many thanks in advance&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Nov 2009 07:11:03 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Calculation-with-Month-s-Last-Day/m-p/204349#M1209063</guid>
      <dc:creator />
      <dc:date>2009-11-16T07:11:03Z</dc:date>
    </item>
    <item>
      <title>Calculation with Month's Last Day</title>
      <link>https://community.qlik.com/t5/QlikView/Calculation-with-Month-s-Last-Day/m-p/204350#M1209064</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Day(Month) gives you the day number in the month, so 22, or 31, or ...&lt;/P&gt;&lt;P&gt;day( '1971-10-30' ) returns 30.&lt;/P&gt;&lt;P&gt;When you subtract the days, you don't automatically receive the right number of days, since there could be a month transition or a period of several months.&lt;/P&gt;&lt;P&gt;What you need it to subtract the day numbers from eachother is the actual number that represents the date. Use Num(Date) to get that number.&lt;/P&gt;&lt;P&gt;Num(Day(ENDMONTH)) - Num(Day(Received))&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Nov 2009 23:07:00 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Calculation-with-Month-s-Last-Day/m-p/204350#M1209064</guid>
      <dc:creator />
      <dc:date>2009-11-20T23:07:00Z</dc:date>
    </item>
    <item>
      <title>Calculation with Month's Last Day</title>
      <link>https://community.qlik.com/t5/QlikView/Calculation-with-Month-s-Last-Day/m-p/204351#M1209065</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I tried but it didn't work&lt;/P&gt;&lt;P&gt;I think there should also be something wrong about the logic because I'm receiving really weird numbers as output&lt;/P&gt;&lt;P&gt;BTW, in the end I managed to have the correct result but really I can't tell why the formula is working.&lt;/P&gt;&lt;P&gt;I used this to take account of substraction when the dates are from different months:&lt;/P&gt;&lt;P&gt;MONTHEND(Received,MONTH-MONTH(Received)) - Received&lt;/P&gt;&lt;P&gt;What is strange is that:&lt;/P&gt;&lt;P&gt;1- I used a no distinct AVG formula&lt;/P&gt;&lt;P&gt;2-I noticed that the output of the nodistinct formula was adding 1 to the correct result, so I used :&lt;/P&gt;&lt;P&gt;(AVG( nodistinct expression) -1).&lt;/P&gt;&lt;P&gt;Honestly, I haven't understood why it is working, there's something I'm missing about logic here&lt;/P&gt;&lt;P&gt;Guess I'll have to make more tests to see if it works even with a different dataset&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 21 Nov 2009 00:04:09 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Calculation-with-Month-s-Last-Day/m-p/204351#M1209065</guid>
      <dc:creator />
      <dc:date>2009-11-21T00:04:09Z</dc:date>
    </item>
    <item>
      <title>Calculation with Month's Last Day</title>
      <link>https://community.qlik.com/t5/QlikView/Calculation-with-Month-s-Last-Day/m-p/204352#M1209066</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In the end it is the result that counts &lt;IMG alt="Wink" src="http://community.qlik.com/emoticons/emotion-5.gif" /&gt;&lt;/P&gt;&lt;P&gt;But it would be nice to know where this behaviour is coming from.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 21 Nov 2009 00:13:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Calculation-with-Month-s-Last-Day/m-p/204352#M1209066</guid>
      <dc:creator />
      <dc:date>2009-11-21T00:13:30Z</dc:date>
    </item>
  </channel>
</rss>

