<?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: Split records - Interval Match ? in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Split-records-Interval-Match/m-p/423560#M157881</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;With some debugging, the FOR loop would generate the dates in the range, but a WHILE loop is easier than a FOR loop:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;LOAD ID,date(Start+iterno()-1) as Date&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;RESIDENT Budgets&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;WHILE Start+iterno()-1 &amp;lt;= End;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But we also only want to allocate the amount to weekdays, and we do need to actually allocate the amount.&amp;nbsp; One way to do it is like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;AllocatedBudgets:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;LOAD *&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;WHERE weekday(Date)&amp;lt;5&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;LOAD &lt;/SPAN&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;ID&lt;/SPAN&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;, date(Start+iterno()-1) as Date&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;RESIDENT Budgets&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;WHILE Start+iterno()-1 &amp;lt;= End&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;LEFT JOIN (Budgets)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;LOAD &lt;/SPAN&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;ID&lt;/SPAN&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;, count(Date) as Weekdays&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;RESIDENT AllocatedBudgets&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;GROUP BY ID&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;LEFT JOIN (AllocatedBudgets)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;LOAD &lt;/SPAN&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;ID&lt;/SPAN&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;, PeriodBudget/Weekdays as AllocatedBudget&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;RESIDENT Budgets&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;See attached.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edit: You could use networkdays() to establish Weekdays during the initial load of the Budgets table, or use it as the join instead of count(Date).&amp;nbsp; I think the count(Date) approach is a little more robust, as you're guaranteed to have the same number, where the networkdays() to me leaves you a little more open to things being out of sync.&amp;nbsp; Also, if you want to add holidays, while you CAN do so with networkdays(), even loading the holidays from a table, it will I think be easier to do it with the count(Date) approach.&amp;nbsp; You just need an additional condition on the WHERE for not exists(Holiday,Date) once you've loaded in your Holidays.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 17 Oct 2012 19:34:26 GMT</pubDate>
    <dc:creator>johnw</dc:creator>
    <dc:date>2012-10-17T19:34:26Z</dc:date>
    <item>
      <title>Split records - Interval Match ?</title>
      <link>https://community.qlik.com/t5/QlikView/Split-records-Interval-Match/m-p/423558#M157879</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;i have the following problem:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- I have calendar table covering the years 2011 to 2013 with one record per day&lt;/P&gt;&lt;P&gt;- I have a table "Budgets" with the following fields:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" cellpadding="3" cellspacing="0" class="jiveBorder" height="70" style="width: 499px; border: 1px solid #000000; height: 72px;" width="497"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH align="center" style="background-color: #6690bc;" valign="middle"&gt;ID&lt;BR /&gt;&lt;/TH&gt;&lt;TH align="center" style="background-color: #6690bc;" valign="middle"&gt;START&lt;BR /&gt;&lt;/TH&gt;&lt;TH align="center" style="background-color: #6690bc;" valign="middle"&gt;END&lt;BR /&gt;&lt;/TH&gt;&lt;TH align="center" style="background-color: #6690bc;" valign="middle"&gt;AMOUNT&lt;BR /&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;123&lt;/TD&gt;&lt;TD&gt;05-04-2012&lt;/TD&gt;&lt;TD&gt;11-30-2012&lt;/TD&gt;&lt;TD&gt;150.000,00&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;456&lt;/TD&gt;&lt;TD&gt;01-01-2012&lt;/TD&gt;&lt;TD&gt;12-31-2012&lt;/TD&gt;&lt;TD&gt;225.000,00&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now i want to every record of the table Budget up to get one record per workday in the period of START and END. Means, i neew something like this after the split:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" cellpadding="3" cellspacing="0" class="jiveBorder" height="116" style="width: 461px; border: 1px solid rgb(0, 0, 0); height: 118px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH align="center" style="background-color: #6690bc;" valign="middle"&gt;ID&lt;BR /&gt;&lt;/TH&gt;&lt;TH align="center" style="background-color: #6690bc;" valign="middle"&gt;START&lt;BR /&gt;&lt;/TH&gt;&lt;TH align="center" style="background-color: #6690bc;" valign="middle"&gt;AMOUNT&lt;BR /&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;123&lt;/TD&gt;&lt;TD&gt;05-04-2012&lt;/TD&gt;&lt;TD&gt;XX.XX&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;123&lt;/TD&gt;&lt;TD&gt;05-07-2012&lt;/TD&gt;&lt;TD&gt;XX.XX&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;123&lt;/TD&gt;&lt;TD&gt;05-08-2012&lt;/TD&gt;&lt;TD&gt;XX.XX&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;BR /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;BR /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;BR /&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;(XX.XX would of course be replaced by Amount/Number of weekdays in period..)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think i first need to calculate the number of weekdays in the period. that i can do. But how would i get the table with one budget record per weekday ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot for help!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Oct 2012 11:55:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Split-records-Interval-Match/m-p/423558#M157879</guid>
      <dc:creator />
      <dc:date>2012-10-17T11:55:51Z</dc:date>
    </item>
    <item>
      <title>Re: Split records - Interval Match ?</title>
      <link>https://community.qlik.com/t5/QlikView/Split-records-Interval-Match/m-p/423559#M157880</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Interval match is not going to work in your sample as the ranges are overlapping.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I guess the only possible solution is to use some kind of loop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TestTable:&lt;/P&gt;&lt;P&gt;LET vBudgetRows = NoOfRows('Budgets');&lt;/P&gt;&lt;P&gt;FOR i = 0 to $(vBudgetRows) - 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LET vBudgetID = Peek('ID', $(i), 'Budgets');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LET vStart = Peek('START', $(i), 'Budgets');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LET vEnd = Peek('END', $(i), 'Budgets');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LOAD $(vBudgetID) as [ID], Date($(vStart) + RecNo()) as [Date] autogenerate $(vEnd) - $(vStart)&lt;/P&gt;&lt;P&gt;NEXT i&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Oct 2012 12:52:56 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Split-records-Interval-Match/m-p/423559#M157880</guid>
      <dc:creator />
      <dc:date>2012-10-17T12:52:56Z</dc:date>
    </item>
    <item>
      <title>Re: Split records - Interval Match ?</title>
      <link>https://community.qlik.com/t5/QlikView/Split-records-Interval-Match/m-p/423560#M157881</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;With some debugging, the FOR loop would generate the dates in the range, but a WHILE loop is easier than a FOR loop:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;LOAD ID,date(Start+iterno()-1) as Date&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;RESIDENT Budgets&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;WHILE Start+iterno()-1 &amp;lt;= End;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But we also only want to allocate the amount to weekdays, and we do need to actually allocate the amount.&amp;nbsp; One way to do it is like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;AllocatedBudgets:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;LOAD *&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;WHERE weekday(Date)&amp;lt;5&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;LOAD &lt;/SPAN&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;ID&lt;/SPAN&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;, date(Start+iterno()-1) as Date&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;RESIDENT Budgets&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;WHILE Start+iterno()-1 &amp;lt;= End&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;LEFT JOIN (Budgets)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;LOAD &lt;/SPAN&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;ID&lt;/SPAN&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;, count(Date) as Weekdays&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;RESIDENT AllocatedBudgets&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;GROUP BY ID&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;LEFT JOIN (AllocatedBudgets)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;LOAD &lt;/SPAN&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;ID&lt;/SPAN&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;, PeriodBudget/Weekdays as AllocatedBudget&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;RESIDENT Budgets&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;See attached.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edit: You could use networkdays() to establish Weekdays during the initial load of the Budgets table, or use it as the join instead of count(Date).&amp;nbsp; I think the count(Date) approach is a little more robust, as you're guaranteed to have the same number, where the networkdays() to me leaves you a little more open to things being out of sync.&amp;nbsp; Also, if you want to add holidays, while you CAN do so with networkdays(), even loading the holidays from a table, it will I think be easier to do it with the count(Date) approach.&amp;nbsp; You just need an additional condition on the WHERE for not exists(Holiday,Date) once you've loaded in your Holidays.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Oct 2012 19:34:26 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Split-records-Interval-Match/m-p/423560#M157881</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2012-10-17T19:34:26Z</dc:date>
    </item>
    <item>
      <title>Re: Split records - Interval Match ?</title>
      <link>https://community.qlik.com/t5/QlikView/Split-records-Interval-Match/m-p/423561#M157882</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Mr. Witherspoon, thank you very much, this works perfectly. &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Oct 2012 09:02:07 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Split-records-Interval-Match/m-p/423561#M157882</guid>
      <dc:creator />
      <dc:date>2012-10-18T09:02:07Z</dc:date>
    </item>
  </channel>
</rss>

