<?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: A complicated case for IntervalMatch in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/A-complicated-case-for-IntervalMatch/m-p/488042#M688817</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi swuehl,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm a bit confused with your example: What is the field &amp;gt;Group&amp;lt;?&lt;/P&gt;&lt;P&gt;You use that in the second LOAD, but I don't see where it comes from?&lt;/P&gt;&lt;P&gt;When you can tell me that, I can tell you if you're close to what I need to do.&lt;/P&gt;&lt;P&gt;In the meantime, I will put together a test_app with some sample data.&lt;/P&gt;&lt;P&gt;Also, I don't quite understand the date# fct. - the integrated help_file is somehow confusing...&lt;/P&gt;&lt;P&gt;I'll be back with my sample app soon.&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DataNibbler&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 06 Nov 2013 13:37:56 GMT</pubDate>
    <dc:creator>datanibbler</dc:creator>
    <dc:date>2013-11-06T13:37:56Z</dc:date>
    <item>
      <title>A complicated case for IntervalMatch</title>
      <link>https://community.qlik.com/t5/QlikView/A-complicated-case-for-IntervalMatch/m-p/488040#M688815</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;can someone help me please? I have a rather complicated scenario I mean to tackle with IntervalMatch - but it's not an easy win.&lt;/P&gt;&lt;P&gt;The issue is about employees and their resp. Cost_Centers. Here is the scenario:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- Any employee has a record in the masterdata table, with his join_date, his leave_date (which is standard 21001231 if the employee is still with us) and a Cost_Center - that never gets updated, it stays until the employee leaves.&lt;/P&gt;&lt;P&gt;- His cost_center, however, might change. In case it does, the new cost_center, with a from_date and a to_date, is in another table.&lt;/P&gt;&lt;P&gt;=&amp;gt; In case the interval(s) recorded in that other tables are over, his cost_center can be switched back.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=&amp;gt; To illustrate what is the difficulty about it, I use a fictitious example:&lt;/P&gt;&lt;P&gt;- There is an employee with the pers_nr 111100000&lt;/P&gt;&lt;P&gt;- He/she joined on 20120801 and is with us up to today (so he/she has a leavedate of 21001231 in the masterdata table)&lt;/P&gt;&lt;P&gt;- In the masterdata table, he/she has a cost_center A&lt;/P&gt;&lt;P&gt;- From 20130101 to 20130830, he/she was assigned cost_center&amp;nbsp; B - that is one record in the other table&lt;/P&gt;&lt;P&gt;- WITHIN that timerange, from 20130401 to 20130620, he/she was assigned cost_center C&lt;/P&gt;&lt;P&gt;- From 20130831 to 21001231, he/she is assigned cost_center D&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In short, the timeranges as recorded in that other table are not sequential, but may be nested in one another.&lt;/P&gt;&lt;P&gt;=&amp;gt; I'd have to somehow make this several intervals. To stick with the example:&lt;/P&gt;&lt;P&gt;- From 20120801 to 20121231, he/she would be assigned to cost_center A&lt;/P&gt;&lt;P&gt;- From 20130101 to 20130331, he/she would&amp;nbsp; have cost_center B&lt;/P&gt;&lt;P&gt;- From 20130401 to 20130620, he/she would have cost_center C&lt;/P&gt;&lt;P&gt;- From 20130621 to 20130830, he/she would have cost_center B&lt;/P&gt;&lt;P&gt;- From 20130831 to 21001231, he/she would have cost_center D&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Simple sorting of the dates won't avail me here for the intervals would be broken in that case.&lt;/P&gt;&lt;P&gt;I will give this some thinking and be back with any news. Any help, however, is appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot!&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DataNibbler&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Nov 2013 12:22:52 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/A-complicated-case-for-IntervalMatch/m-p/488040#M688815</guid>
      <dc:creator>datanibbler</dc:creator>
      <dc:date>2013-11-06T12:22:52Z</dc:date>
    </item>
    <item>
      <title>Re: A complicated case for IntervalMatch</title>
      <link>https://community.qlik.com/t5/QlikView/A-complicated-case-for-IntervalMatch/m-p/488041#M688816</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Friedrich,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;it would make things a little easier if you could attach some sample input data in an appropriate format or even a small sample app.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In principle, I think you can try something like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Set DateFormat ='YYYYMMDD';&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;INPUT:&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;LOAD date#(Start) as Start, date#(End) as End, Center INLINE [&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Start, End, Center&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;20120801, 20121231,&amp;nbsp; A&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;20130101, 20130830,&amp;nbsp; B&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;20130401, 20130620,&amp;nbsp; C&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;20130831, 20131231,&amp;nbsp; D&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;];&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;TMP:&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;LOAD *, Date(Start+iterno()-1) as Date Resident INPUT while Start+iterno()-1 &amp;lt;= End order by Start asc;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;drop table INPUT;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;TMP2:&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;LOAD *, &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(Center&amp;lt;&amp;gt; peek(Center),rangesum(1,peek(Group)),peek(Group)) as Group;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;LOAD Date, &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LastValue(Center) as Center, &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LastValue(Start) as Start &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Resident TMP group by Date;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;drop table TMP;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;RESULT:&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;LOAD Group, &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; date(min(Date)) as Start, &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; date(max(Date)) as End, &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; only(Center) as Center &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Resident TMP2 Group by Group;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;drop table TMP2;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can probably already use TMP2 table for what you finally need, this is already a flat table with the Center allocation for each Date.&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Nov 2013 13:20:08 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/A-complicated-case-for-IntervalMatch/m-p/488041#M688816</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2013-11-06T13:20:08Z</dc:date>
    </item>
    <item>
      <title>Re: A complicated case for IntervalMatch</title>
      <link>https://community.qlik.com/t5/QlikView/A-complicated-case-for-IntervalMatch/m-p/488042#M688817</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi swuehl,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm a bit confused with your example: What is the field &amp;gt;Group&amp;lt;?&lt;/P&gt;&lt;P&gt;You use that in the second LOAD, but I don't see where it comes from?&lt;/P&gt;&lt;P&gt;When you can tell me that, I can tell you if you're close to what I need to do.&lt;/P&gt;&lt;P&gt;In the meantime, I will put together a test_app with some sample data.&lt;/P&gt;&lt;P&gt;Also, I don't quite understand the date# fct. - the integrated help_file is somehow confusing...&lt;/P&gt;&lt;P&gt;I'll be back with my sample app soon.&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DataNibbler&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Nov 2013 13:37:56 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/A-complicated-case-for-IntervalMatch/m-p/488042#M688817</guid>
      <dc:creator>datanibbler</dc:creator>
      <dc:date>2013-11-06T13:37:56Z</dc:date>
    </item>
    <item>
      <title>Re: A complicated case for IntervalMatch</title>
      <link>https://community.qlik.com/t5/QlikView/A-complicated-case-for-IntervalMatch/m-p/488043#M688818</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You should be able to just copy the code into your editor and let it load, this should create a final table which I think should match what you expect.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Group is created with this load expression:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp; if(Center&amp;lt;&amp;gt; peek(Center),rangesum(1,peek(Group)),peek(Group)) as Group&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It just numbers the consecutive sequence of dates one is belonging to the same Center.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think the date#() function should be explained in the Help or ref manual, and also here:&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.qlik.com/docs/DOC-3102"&gt;QlikView Date fields&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Nov 2013 13:44:23 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/A-complicated-case-for-IntervalMatch/m-p/488043#M688818</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2013-11-06T13:44:23Z</dc:date>
    </item>
    <item>
      <title>Re: Re: A complicated case for IntervalMatch</title>
      <link>https://community.qlik.com/t5/QlikView/A-complicated-case-for-IntervalMatch/m-p/488044#M688819</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;Hi swuehl,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think I kind of understand. I have to give this some more thought.&lt;/P&gt;&lt;P&gt;If I understand this point correctly, however, your table TMP is just a "blowup" of what you get from INPUT.&lt;/P&gt;&lt;P&gt;=&amp;gt; If the last interval in that table has an end_date of 21001231, that would create a lot of unneeded data, but that could be helped by replacing that with today's date.&lt;/P&gt;&lt;P&gt;Here is the sample app I put together, exactly like it is in this example - with a little twist: The last interval in that table (INPUT) has an end_date of 21001231 - but as you see in the masterdata table, that employee left on 20130831.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Nov 2013 13:50:37 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/A-complicated-case-for-IntervalMatch/m-p/488044#M688819</guid>
      <dc:creator>datanibbler</dc:creator>
      <dc:date>2013-11-06T13:50:37Z</dc:date>
    </item>
    <item>
      <title>Re: Re: A complicated case for IntervalMatch</title>
      <link>https://community.qlik.com/t5/QlikView/A-complicated-case-for-IntervalMatch/m-p/488045#M688820</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;Hi swuehl,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tested your code and it is quite close to what I need - but not altogether there. Also, I don't understand why it does what it does and that's not acceptable - I'll have to work on this &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;&lt;P&gt;However - your code assigns the employee two cost_centers between 20130401 and 20130620. There can be only one, however and there's no exact telling (from the numerical value or a letter) which one is correct.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Nov 2013 14:06:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/A-complicated-case-for-IntervalMatch/m-p/488045#M688820</guid>
      <dc:creator>datanibbler</dc:creator>
      <dc:date>2013-11-06T14:06:42Z</dc:date>
    </item>
    <item>
      <title>Re: Re: A complicated case for IntervalMatch</title>
      <link>https://community.qlik.com/t5/QlikView/A-complicated-case-for-IntervalMatch/m-p/488046#M688821</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;sorry, I had overlooked the last DROP TABLE.&lt;/P&gt;&lt;P&gt;Now that I have it, your code actually does give me exactly what I want - I only have to think my way through how it is done.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot!&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DataNibbler&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Nov 2013 14:11:40 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/A-complicated-case-for-IntervalMatch/m-p/488046#M688821</guid>
      <dc:creator>datanibbler</dc:creator>
      <dc:date>2013-11-06T14:11:40Z</dc:date>
    </item>
    <item>
      <title>Re: Re: Re: A complicated case for IntervalMatch</title>
      <link>https://community.qlik.com/t5/QlikView/A-complicated-case-for-IntervalMatch/m-p/488047#M688822</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, it's just a blow up of your intervals. But you probably need to do something similar anyway, somepoint in your code.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Nov 2013 14:19:03 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/A-complicated-case-for-IntervalMatch/m-p/488047#M688822</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2013-11-06T14:19:03Z</dc:date>
    </item>
    <item>
      <title>Re: A complicated case for IntervalMatch</title>
      <link>https://community.qlik.com/t5/QlikView/A-complicated-case-for-IntervalMatch/m-p/488048#M688823</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks a lot!&lt;/P&gt;&lt;P&gt;Your code works and does what I want, the greatest part of it anyway. It's only for one employee, but well, it can be looped over for everyone, it will just take a while. No problem on the technical side.&lt;/P&gt;&lt;P&gt;Now it's up to me, I will think my way through it and build on it to get exactly what we need.&lt;/P&gt;&lt;P&gt;Thanks again!&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DataNibbler&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Nov 2013 14:28:44 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/A-complicated-case-for-IntervalMatch/m-p/488048#M688823</guid>
      <dc:creator>datanibbler</dc:creator>
      <dc:date>2013-11-06T14:28:44Z</dc:date>
    </item>
    <item>
      <title>Re: A complicated case for IntervalMatch</title>
      <link>https://community.qlik.com/t5/QlikView/A-complicated-case-for-IntervalMatch/m-p/488049#M688824</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;Hi swuehl,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;now I've found out just what your code is doing. You were right, I don't need that last table RESULT, I can stop when I have TMP2.&lt;/P&gt;&lt;P&gt;Accordingly, I also deleted the first of that double-set of LOAD statements and I understand the LastValue() concept now.&lt;/P&gt;&lt;P&gt;Now I just have to insert the SQL SELECTs to get the info from our database and then I have to find a way of looping over every employee and doing all this for every one - though some might not have those interim_cost_centers at all, so maybe I can skip that operation for those and just assume the default_cost_center for every day for them.&lt;/P&gt;&lt;P&gt;When that works, we'll be a big step further along the way to getting our calculations straight.&lt;/P&gt;&lt;P&gt;Thanks again!&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DataNibbler&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Nov 2013 16:20:44 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/A-complicated-case-for-IntervalMatch/m-p/488049#M688824</guid>
      <dc:creator>datanibbler</dc:creator>
      <dc:date>2013-11-06T16:20:44Z</dc:date>
    </item>
  </channel>
</rss>

