<?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: Multiple Ships and Returns - Unwanted Combinations in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Multiple-Ships-and-Returns-Unwanted-Combinations/m-p/453769#M169316</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You are welcome.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the join in my above sample costs to much time in your real setting, consider replacing it with a mapping table:&lt;/P&gt;&lt;P&gt;&lt;A _jive_internal="true" class="loading" href="https://community.qlik.com/blogs/qlikviewdesignblog/2012/09/18/one-favorite-function-applymap"&gt;http://community.qlik.com/blogs/qlikviewdesignblog/2012/09/18/one-favorite-function-applymap&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You just need to create a unique key out of SerNo and ID to make this work.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 01 Oct 2012 18:34:52 GMT</pubDate>
    <dc:creator>swuehl</dc:creator>
    <dc:date>2012-10-01T18:34:52Z</dc:date>
    <item>
      <title>Multiple Ships and Returns - Unwanted Combinations</title>
      <link>https://community.qlik.com/t5/QlikView/Multiple-Ships-and-Returns-Unwanted-Combinations/m-p/453764#M169311</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;I have a dilemma I'm not able to fix. The data I have is in separate ship and return tables, and any serial number can be shipped multiple times and returned multiple times. What I'm ending up with in my tables are every possible combination of ship and return, but need to eliminate the phantom ones and retain only the real ones. The data is pulled from an Oracle DB, sorted by serial number then date ascending, then saved into separate qvd's for use in multiple dashboards.&lt;/DIV&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt;This is inline code I used to simulate one serial number possibility, but of course there are many serial numbers:&lt;/DIV&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt;SampleShip:&lt;/DIV&gt;&lt;DIV&gt;Load * Inline [SerNo,ShipDate&lt;/DIV&gt;&lt;DIV&gt; 103828,38560&lt;/DIV&gt;&lt;DIV&gt; 103828,38803&lt;/DIV&gt;&lt;DIV&gt; 103828,39037&lt;/DIV&gt;&lt;DIV&gt; 103828,39127];&lt;/DIV&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt;SampleReturn:&lt;/DIV&gt;&lt;DIV&gt;Load * Inline [SerNo,ReturnDate&lt;/DIV&gt;&lt;DIV&gt; 103828,38778&lt;/DIV&gt;&lt;DIV&gt; 103828,38958&lt;/DIV&gt;&lt;DIV&gt; 103828,39087];&lt;/DIV&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt;So, for this perticular serial number this is how my table ends up when I use the following expression:&lt;/DIV&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt;Difference =&lt;/DIV&gt;&lt;DIV&gt;if(ReturnDate&amp;lt;&amp;gt;Null(),Num(if(ReturnDate-ShipDate&amp;gt;0, ((ReturnDate-ShipDate)/Count(SerNo)/30.42)),'#,###.0'), Num(((Today()-ShipDate)/30.42),'#,###.0'))&lt;/DIV&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt;&lt;TABLE border="1" cellpadding="3" cellspacing="0" class="jiveBorder" style="width: 25%; border: 1px solid #000000;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH align="center" style="background-color: #6690bc;" valign="middle"&gt;&lt;SPAN style="color: #ffffff;"&gt;&lt;STRONG&gt;SerNo&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/TH&gt;&lt;TH align="center" style="background-color: #6690bc;" valign="middle"&gt;&lt;SPAN style="color: #ffffff;"&gt;&lt;STRONG&gt;ShipDate&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/TH&gt;&lt;TH align="center" style="background-color: #6690bc;" valign="middle"&gt;&lt;SPAN style="color: #ffffff;"&gt;&lt;STRONG&gt;ReturnDate&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/TH&gt;&lt;TH align="center" style="background-color: #6690bc;" valign="middle"&gt;&lt;SPAN style="color: #ffffff;"&gt;&lt;STRONG&gt;Difference&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/TH&gt;&lt;TH align="center" style="background-color: #6690bc;" valign="middle"&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;103828&lt;/TD&gt;&lt;TD&gt;38560&lt;/TD&gt;&lt;TD&gt;38778&lt;/TD&gt;&lt;TD&gt;7.2&lt;/TD&gt;&lt;TD style="background-color: rgb(246, 165, 8);"&gt;good&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;103828&lt;/TD&gt;&lt;TD&gt;38560&lt;/TD&gt;&lt;TD&gt;38958&lt;/TD&gt;&lt;TD&gt;13.1&lt;/TD&gt;&lt;TD style="background-color: rgb(246, 165, 8);"&gt;bad&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;103828&lt;/TD&gt;&lt;TD&gt;38560&lt;/TD&gt;&lt;TD&gt;39037&lt;/TD&gt;&lt;TD&gt;17.3&lt;/TD&gt;&lt;TD style="background-color: rgb(246, 165, 8);"&gt;bad&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;103828&lt;/TD&gt;&lt;TD&gt;38803&lt;/TD&gt;&lt;TD&gt;38958&lt;/TD&gt;&lt;TD&gt;5.1&lt;/TD&gt;&lt;TD style="background-color: rgb(246, 165, 8);"&gt;good&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;103828&lt;/TD&gt;&lt;TD&gt;38803&lt;/TD&gt;&lt;TD&gt;39087&lt;/TD&gt;&lt;TD&gt;9.3&lt;/TD&gt;&lt;TD style="background-color: rgb(246, 165, 8);"&gt;bad&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;103828&lt;/TD&gt;&lt;TD&gt;39037&lt;/TD&gt;&lt;TD&gt;39087&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;1.6&lt;/P&gt;&lt;/TD&gt;&lt;TD style="background-color: rgb(246, 165, 8);"&gt;good&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt;Here is what I need it to look like:&lt;/DIV&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt;&lt;TABLE border="1" cellpadding="3" cellspacing="0" class="jiveBorder" style="width: 25%; border: 1px solid #000000;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH align="center" style="background-color: #6690bc;" valign="middle"&gt;&lt;SPAN style="color: #ffffff;"&gt;&lt;STRONG&gt;SerNo&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/TH&gt;&lt;TH align="center" style="background-color: #6690bc;" valign="middle"&gt;&lt;SPAN style="color: #ffffff;"&gt;&lt;STRONG&gt;ShipDate&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/TH&gt;&lt;TH align="center" style="background-color: #6690bc;" valign="middle"&gt;&lt;SPAN style="color: #ffffff;"&gt;&lt;STRONG&gt;ReturnDate&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/TH&gt;&lt;TH align="center" style="background-color: #6690bc;" valign="middle"&gt;&lt;SPAN style="color: #ffffff;"&gt;&lt;STRONG&gt;Difference&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;103828&lt;/TD&gt;&lt;TD&gt;38560&lt;/TD&gt;&lt;TD&gt;38778&lt;/TD&gt;&lt;TD&gt;7.2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;103828&lt;/TD&gt;&lt;TD&gt;38803&lt;/TD&gt;&lt;TD&gt;38958&lt;/TD&gt;&lt;TD&gt;5.1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;103828&lt;/TD&gt;&lt;TD&gt;39037&lt;/TD&gt;&lt;TD&gt;39087&lt;/TD&gt;&lt;TD&gt;1.6&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;103828&lt;/TD&gt;&lt;TD&gt;39127&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;-&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;BR /&gt;Since the last ship date (39127) does not have a corresponding return date it doesn't show in the table, but I will ultimatelty need to add this row and include today's date as the Return Date. Assuming today = 41180 (9/28/2012) It would look like this:&lt;/DIV&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt;&lt;TABLE border="1" cellpadding="3" cellspacing="0" class="jiveBorder" style="width: 25%; border: 1px solid #000000;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH align="center" style="background-color: #6690bc;" valign="middle"&gt;&lt;SPAN style="color: #ffffff;"&gt;&lt;STRONG&gt;SerNo&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/TH&gt;&lt;TH align="center" style="background-color: #6690bc;" valign="middle"&gt;&lt;SPAN style="color: #ffffff;"&gt;&lt;STRONG&gt;ShipDate&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/TH&gt;&lt;TH align="center" style="background-color: #6690bc;" valign="middle"&gt;&lt;SPAN style="color: #ffffff;"&gt;&lt;STRONG&gt;ReturnDate or CurrentDate&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/TH&gt;&lt;TH align="center" style="background-color: #6690bc;" valign="middle"&gt;&lt;SPAN style="color: #ffffff;"&gt;&lt;STRONG&gt;Difference&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;103828&lt;/TD&gt;&lt;TD&gt;38560&lt;/TD&gt;&lt;TD&gt;38778&lt;/TD&gt;&lt;TD&gt;7.2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;103828&lt;/TD&gt;&lt;TD&gt;38803&lt;/TD&gt;&lt;TD&gt;38958&lt;/TD&gt;&lt;TD&gt;5.1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;103828&lt;/TD&gt;&lt;TD&gt;39037&lt;/TD&gt;&lt;TD&gt;39087&lt;/TD&gt;&lt;TD&gt;1.6&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;103828&lt;/TD&gt;&lt;TD&gt;39127&lt;/TD&gt;&lt;TD&gt;41180&lt;/TD&gt;&lt;TD&gt;67.5&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've tried adding a counter ("-1", "-2", "-3", etc) to each serial number and linking with that, but it breaks if I am missing a shipment or return record, and this is the case over and over so not an option.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have any of you gone down this path before and come up with a solution? I have yet to find one. Appreciate any solutions that will get me close than I am.&amp;nbsp; --john&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Sep 2012 15:33:15 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Multiple-Ships-and-Returns-Unwanted-Combinations/m-p/453764#M169311</guid>
      <dc:creator>johnca</dc:creator>
      <dc:date>2012-09-28T15:33:15Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Ships and Returns - Unwanted Combinations</title>
      <link>https://community.qlik.com/t5/QlikView/Multiple-Ships-and-Returns-Unwanted-Combinations/m-p/453765#M169312</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Henric will probably kill me because I am using a join here:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;SampleShip:&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Load *,AutoNumber(ShipDate,SerNo&amp;amp;'Sam') as ShipID Inline [&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;SerNo,ShipDate&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;103828,38560&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;103828,38803&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;103828,39037&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;103828,39127];&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;SampleReturn:&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Left join Load *, autonumber(ReturnDate,SerNo&amp;amp;'Ret') as ShipID Inline [&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;SerNo,ReturnDate&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;103828,38778&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;103828,38958&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;103828,39087];&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;gt; "&lt;/EM&gt;I've tried adding a counter ("-1", "-2", "-3", etc) to each serial number and linking with that, but it breaks if I am missing a shipment or return record, and this is the case over and over so not an option."&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sorry, I think I haven't fully understood this part. You are missing some records? How do you link ShipDates and ReturnDates then?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Sep 2012 17:23:12 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Multiple-Ships-and-Returns-Unwanted-Combinations/m-p/453765#M169312</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2012-09-28T17:23:12Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Ships and Returns - Unwanted Combinations</title>
      <link>https://community.qlik.com/t5/QlikView/Multiple-Ships-and-Returns-Unwanted-Combinations/m-p/453766#M169313</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That is similar to adding a counter to each record. If I have all the records it works…if I’m missing a record it doesn’t. For instance, try removing the first SampleShip record “103828,38560” and see what happens. You get a return record earlier than the ship record.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The counter I refer to is adding a “-1”, “-2”, “-3”, etc for each serial number’s ship record using the following: (assuming the data has already been sorted by serial number then date)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if(Previous(ShipDate) &amp;lt;&amp;gt; ShipDate, 1,  peek(Counter) + 1) as Counter,*;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So the new field Counter data would look like 103828-1, 103828-2, 103828-3, etc. Doing the same with return records allows me to join on that field, but if I’m missing any record it breaks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I did learn something though…thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Sep 2012 19:20:00 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Multiple-Ships-and-Returns-Unwanted-Combinations/m-p/453766#M169313</guid>
      <dc:creator>johnca</dc:creator>
      <dc:date>2012-09-28T19:20:00Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Ships and Returns - Unwanted Combinations</title>
      <link>https://community.qlik.com/t5/QlikView/Multiple-Ships-and-Returns-Unwanted-Combinations/m-p/453767#M169314</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok, I think I understand now.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Well, if you are coping with missing records, but still want to calculate something, I think you need to set up some rules and make some assumptions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;An assumption I've made: If you are ordering your shipment / return dates by date for a given SerNo, there are no 2 subsequent records missing.&lt;/P&gt;&lt;P&gt;For example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SerNo, Date, Type&lt;/P&gt;&lt;P&gt;1, 30200, Ship&lt;/P&gt;&lt;P&gt;1, 30201, Return&lt;/P&gt;&lt;P&gt;1, 30202, Ship&lt;/P&gt;&lt;P&gt;1, 30203, Return&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you remove the second and third record, you get a valid combinatin of Shipment and Return, but your calculation of the date difference is quite off, right?&lt;/P&gt;&lt;P&gt;Since you don't know which records are missing, all you can do is hoping that your assumption is mostly correct.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then you can set up some rules, how to handle e.g.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SerNo, Date, Type&lt;/P&gt;&lt;P&gt;1, 30200, Ship&lt;/P&gt;&lt;P&gt;1, 30201, Return&lt;/P&gt;&lt;P&gt;1, 30203, Return&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In this case, I assume you want to remove the second return record from your calculation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SerNo, Date, Type&lt;/P&gt;&lt;P&gt;1, 30200, Ship&lt;/P&gt;&lt;P&gt;1, 30201, Ship&lt;/P&gt;&lt;P&gt;1, 30202, Return&lt;/P&gt;&lt;P&gt;1, 30203, Ship&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here I assume that you want to keep all Ship records and link the Return to the second Shipment. The first and third Shipment will have no Return record, and you can assign e.g. today() in your chart as Return if needed (as I did in my last post).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can create a script that handles these rules like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Sample:&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Load SerNo, 'Ship' as Type, ShipDate as Date&amp;nbsp; Inline [&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;SerNo,ShipDate&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;103828,38560&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;103828,38803&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;103828,39037&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;103828,39127&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;103829,39127&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;Load SerNo, 'Return' as Type, ReturnDate as Date&amp;nbsp; Inline [&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;SerNo,ReturnDate&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;103828,38778&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;103828,38958&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;103828,39087&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;103829,39128];&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 *, &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;if(Type ='Ship', autonumber(recno(),SerNo), if(peek(Type)='Ship' and peek(SerNo) = SerNo, peek(ID))) as ID&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt; Resident Sample order by SerNo, Date;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Drop table Sample;&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 SerNo, Date as ShipDate, ID Resident TMP where Type = 'Ship';&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;left join LOAD SerNo, Date as ReturnDate, ID Resident TMP where Type = 'Return';&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;The trick is creating a table with all records for a SerNo ordered by Date, and then create an ID based on the rules. Then you can either just use this TMP table or create again a table with split up fields for ShipDate and ReturnDate (RESULT).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps,&lt;/P&gt;&lt;P&gt;Stefan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 29 Sep 2012 11:38:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Multiple-Ships-and-Returns-Unwanted-Combinations/m-p/453767#M169314</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2012-09-29T11:38:42Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Ships and Returns - Unwanted Combinations</title>
      <link>https://community.qlik.com/t5/QlikView/Multiple-Ships-and-Returns-Unwanted-Combinations/m-p/453768#M169315</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Stefan, I am astonished the answer was possible at all. I applied this to a much larger dataset and it works flawlessly, without adding unwanted combinations and actually knowing which return record belonged to which shipment. Amazing! The only unfortunate part is that it takes quite a while to run on my larger dataset, so I'll need to play with incremental loading. Again, much thanks!&lt;/P&gt;&lt;P&gt;--john&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Oct 2012 18:29:00 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Multiple-Ships-and-Returns-Unwanted-Combinations/m-p/453768#M169315</guid>
      <dc:creator>johnca</dc:creator>
      <dc:date>2012-10-01T18:29:00Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Ships and Returns - Unwanted Combinations</title>
      <link>https://community.qlik.com/t5/QlikView/Multiple-Ships-and-Returns-Unwanted-Combinations/m-p/453769#M169316</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You are welcome.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the join in my above sample costs to much time in your real setting, consider replacing it with a mapping table:&lt;/P&gt;&lt;P&gt;&lt;A _jive_internal="true" class="loading" href="https://community.qlik.com/blogs/qlikviewdesignblog/2012/09/18/one-favorite-function-applymap"&gt;http://community.qlik.com/blogs/qlikviewdesignblog/2012/09/18/one-favorite-function-applymap&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You just need to create a unique key out of SerNo and ID to make this work.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Oct 2012 18:34:52 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Multiple-Ships-and-Returns-Unwanted-Combinations/m-p/453769#M169316</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2012-10-01T18:34:52Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Ships and Returns - Unwanted Combinations</title>
      <link>https://community.qlik.com/t5/QlikView/Multiple-Ships-and-Returns-Unwanted-Combinations/m-p/453770#M169317</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm somewhat familiar with the Mapping function, and have seen it used in a similar manner but wasn't sure how it did its thing. I'm used to simple maps so this will be a challenge, but not impossible. Again, much gratitude.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Oct 2012 19:38:01 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Multiple-Ships-and-Returns-Unwanted-Combinations/m-p/453770#M169317</guid>
      <dc:creator>johnca</dc:creator>
      <dc:date>2012-10-02T19:38:01Z</dc:date>
    </item>
  </channel>
</rss>

