<?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: Number of months from today till date spread across Years in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Number-of-months-from-today-till-date-spread-across-Years/m-p/1771402#M717846</link>
    <description>&lt;P&gt;I've attached almost full load script before but here you go.&lt;/P&gt;</description>
    <pubDate>Thu, 31 Dec 2020 16:56:05 GMT</pubDate>
    <dc:creator>mfchmielowski</dc:creator>
    <dc:date>2020-12-31T16:56:05Z</dc:date>
    <item>
      <title>Number of months from today till date spread across Years</title>
      <link>https://community.qlik.com/t5/QlikView/Number-of-months-from-today-till-date-spread-across-Years/m-p/1771113#M717841</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="qlikwiz123_0-1609272444417.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/46279iAA91224BD7AC3E16/image-size/medium?v=v2&amp;amp;px=400" role="button" title="qlikwiz123_0-1609272444417.png" alt="qlikwiz123_0-1609272444417.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;From today in 2020 to 2023 March, there are 28 months. I am able to show the number of months from today and the final date but not able to split it between years. For example, 2020 has only one month left. So it should be 1. In 2023, since final date is 03/31/2023, NoOfMonths should be 3.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2020 - 1&lt;/P&gt;&lt;P&gt;2021 - 12&lt;/P&gt;&lt;P&gt;2022 - 12&lt;/P&gt;&lt;P&gt;2023 - 3&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 17:39:53 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Number-of-months-from-today-till-date-spread-across-Years/m-p/1771113#M717841</guid>
      <dc:creator>qlikwiz123</dc:creator>
      <dc:date>2024-11-16T17:39:53Z</dc:date>
    </item>
    <item>
      <title>Re: Number of months from today till date spread across Years</title>
      <link>https://community.qlik.com/t5/QlikView/Number-of-months-from-today-till-date-spread-across-Years/m-p/1771144#M717842</link>
      <description>&lt;P&gt;You are not telling us how you are calculating in order to get 28 for all years, but you could take a look at this old post to check if it will be of help: &lt;A href="https://community.qlik.com/t5/QlikView-Documents/Calculating-Months-difference-between-two-dates/ta-p/1486518" target="_blank"&gt;https://community.qlik.com/t5/QlikView-Documents/Calculating-Months-difference-between-two-dates/ta-p/1486518&lt;/A&gt; . It gives an example on how to calculate no of months between two dates.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Dec 2020 08:24:49 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Number-of-months-from-today-till-date-spread-across-Years/m-p/1771144#M717842</guid>
      <dc:creator>Vegar</dc:creator>
      <dc:date>2020-12-30T08:24:49Z</dc:date>
    </item>
    <item>
      <title>Re: Number of months from today till date spread across Years</title>
      <link>https://community.qlik.com/t5/QlikView/Number-of-months-from-today-till-date-spread-across-Years/m-p/1771198#M717843</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I already have this&amp;nbsp; to calculate the number of months from Today and the Final Date. But as you can see, it is showing the same number of months (28) for all the years while it is not true (2020 only has one month left and 2023 only has 3 months since the Final Date is 03/31/2023). I want to distribute these 28 months into the respective years.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have my Data and expected output in my question too.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Dec 2020 13:37:58 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Number-of-months-from-today-till-date-spread-across-Years/m-p/1771198#M717843</guid>
      <dc:creator>qlikwiz123</dc:creator>
      <dc:date>2020-12-30T13:37:58Z</dc:date>
    </item>
    <item>
      <title>Re: Number of months from today till date spread across Years</title>
      <link>https://community.qlik.com/t5/QlikView/Number-of-months-from-today-till-date-spread-across-Years/m-p/1771208#M717844</link>
      <description>&lt;P&gt;I think that You need to have more information columns. Not only year.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My sample below, without commets but it's reable &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;let finalDate = date('2023-03-31', 'YYYY-MM-DD');

Table:
load
	*
	, if(year(dateYearStart) &amp;lt;&amp;gt; year('$(finalDate)')
		, if(year(date) = year(today(1))
			, (year(dateYearEnd) * 12 + num(month(dateYearEnd))) -  (year(dateMonthStart) * 12 + num(month(dateMonthStart))) + 1
			, (year(dateYearEnd) * 12 + num(month(dateYearEnd))) -  (year(dateYearStart) * 12 + num(month(dateYearStart))) + 1
		)
		, (2023*12 + 3) - (year(dateYearStart) * 12 + num(month(dateYearStart))) + 1
	) as monthsTillEndYearOrFinal
;
load *
	, monthStart(date) as dateMonthStart
	, yearStart(date) as dateYearStart
	, YearEnd(date) as dateYearEnd
	, year(date) as dateYear
inline [
	date
	2020-12-30
	2021-01-01
	2021-02-01
	2022-01-01
	2022-12-01
	2023-01-01
	2023-02-01
	2023-02-01
];&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Result table looks like this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="resultTable.png" style="width: 307px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/46286i53C61A5C216AD355/image-size/large?v=v2&amp;amp;px=999" role="button" title="resultTable.png" alt="resultTable.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Dec 2020 14:31:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Number-of-months-from-today-till-date-spread-across-Years/m-p/1771208#M717844</guid>
      <dc:creator>mfchmielowski</dc:creator>
      <dc:date>2020-12-30T14:31:25Z</dc:date>
    </item>
    <item>
      <title>Re: Number of months from today till date spread across Years</title>
      <link>https://community.qlik.com/t5/QlikView/Number-of-months-from-today-till-date-spread-across-Years/m-p/1771396#M717845</link>
      <description>&lt;P&gt;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/46674"&gt;@mfchmielowski&lt;/a&gt;&amp;nbsp; Is it possible to attach the QVW please?&lt;/P&gt;</description>
      <pubDate>Thu, 31 Dec 2020 15:48:02 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Number-of-months-from-today-till-date-spread-across-Years/m-p/1771396#M717845</guid>
      <dc:creator>qlikwiz123</dc:creator>
      <dc:date>2020-12-31T15:48:02Z</dc:date>
    </item>
    <item>
      <title>Re: Number of months from today till date spread across Years</title>
      <link>https://community.qlik.com/t5/QlikView/Number-of-months-from-today-till-date-spread-across-Years/m-p/1771402#M717846</link>
      <description>&lt;P&gt;I've attached almost full load script before but here you go.&lt;/P&gt;</description>
      <pubDate>Thu, 31 Dec 2020 16:56:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Number-of-months-from-today-till-date-spread-across-Years/m-p/1771402#M717846</guid>
      <dc:creator>mfchmielowski</dc:creator>
      <dc:date>2020-12-31T16:56:05Z</dc:date>
    </item>
    <item>
      <title>Re: Number of months from today till date spread across Years</title>
      <link>https://community.qlik.com/t5/QlikView/Number-of-months-from-today-till-date-spread-across-Years/m-p/1771406#M717847</link>
      <description>&lt;P&gt;I see that you are manually creating dates for every month.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I only have&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ID&lt;/STRONG&gt;, &lt;STRONG&gt;Final Date&lt;/STRONG&gt; as my columns where I am generating &lt;STRONG&gt;Year(Final Date)&lt;/STRONG&gt; to create &lt;STRONG&gt;Year&lt;/STRONG&gt; field.&lt;/P&gt;&lt;P&gt;How do I count months in this case and also make the Final Date Dynamic instead of hard quoting it in Variable?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 31 Dec 2020 17:54:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Number-of-months-from-today-till-date-spread-across-Years/m-p/1771406#M717847</guid>
      <dc:creator>qlikwiz123</dc:creator>
      <dc:date>2020-12-31T17:54:41Z</dc:date>
    </item>
    <item>
      <title>Re: Number of months from today till date spread across Years</title>
      <link>https://community.qlik.com/t5/QlikView/Number-of-months-from-today-till-date-spread-across-Years/m-p/1771411#M717848</link>
      <description>&lt;P&gt;Yes, i've created dates table manualy &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; i don't have your input table.&lt;BR /&gt;You can always generate calendar table since today() to some final date and adapt code to it. The variable value can be peek'ed from table.&lt;/P&gt;&lt;P&gt;I've upgraded code and attached.&lt;/P&gt;</description>
      <pubDate>Thu, 31 Dec 2020 19:53:02 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Number-of-months-from-today-till-date-spread-across-Years/m-p/1771411#M717848</guid>
      <dc:creator>mfchmielowski</dc:creator>
      <dc:date>2020-12-31T19:53:02Z</dc:date>
    </item>
  </channel>
</rss>

