<?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: Load earliest date but when another field value matches a specific value. in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Load-earliest-date-but-when-another-field-value-matches-a/m-p/2047446#M86151</link>
    <description>&lt;P&gt;Thanks&amp;nbsp;Marijn,&lt;BR /&gt;I will have a look later today or tomorrow asap and come back with an update/mark as solution etc.&lt;/P&gt;
&lt;P&gt;Appreciate the time you have taken,&lt;/P&gt;
&lt;P&gt;Regards Daryn&lt;/P&gt;</description>
    <pubDate>Thu, 09 Mar 2023 14:31:42 GMT</pubDate>
    <dc:creator>Daryn</dc:creator>
    <dc:date>2023-03-09T14:31:42Z</dc:date>
    <item>
      <title>Load earliest date but when another field value matches a specific value.</title>
      <link>https://community.qlik.com/t5/App-Development/Load-earliest-date-but-when-another-field-value-matches-a/m-p/2046286#M86063</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;Thanks for reading this and assisting if possible.&lt;/P&gt;
&lt;P&gt;I have the above load script below in place and working,&lt;/P&gt;
&lt;P&gt;---------------------------------------------------------------------------------------------------&lt;BR /&gt;[Vehicles]:&lt;/P&gt;
&lt;P&gt;LOAD&lt;BR /&gt;Material,&lt;BR /&gt;Quantity,&lt;BR /&gt;MvT,&lt;BR /&gt;Date#([Entry Date])&lt;BR /&gt;Batch,&lt;BR /&gt;FROM [lib://AttachedFiles/Vehicles.xlsx]&lt;BR /&gt;(txt, unicode, embedded labels, delimiter is '\t', msq) ;&lt;/P&gt;
&lt;P&gt;---------------------------------------------------------------------------------------------------&lt;/P&gt;
&lt;P&gt;But, the field 'Entry Date' contains all dates for vehicles of two movement types (MvT).&lt;/P&gt;
&lt;P&gt;MvT = 501 (is a van booked in)&lt;/P&gt;
&lt;P&gt;MvT = 281 (is a van booked out)&lt;/P&gt;
&lt;P&gt;Now the issue, that some vehicles are booked in and out, more than once (coming back perhaps for warranty work) or human error in the booking process.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would just like to load the first date for each MvT, against the field 'Batch'&amp;nbsp; (this field remains the same against each movement type for each vehicle).&lt;/P&gt;
&lt;P&gt;I guess I am looking for a way of applying MvT = '281'&amp;nbsp; &amp;nbsp; or the '501' to something like the below?&lt;/P&gt;
&lt;P&gt;Batch, Min([Entry Date]) AS DATE501,&lt;BR /&gt;Batch, Min([Entry Date]) AS DATE281&lt;/P&gt;
&lt;P&gt;GROUP BY Batch;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I also tried to work it out using a couple of new variables;&lt;/P&gt;
&lt;P&gt;If(MvT = '281', [Entry Date]) AS [Date Out],&lt;BR /&gt;If(MvT = '501', [Entry Date]) AS [Date In],&lt;/P&gt;
&lt;P&gt;But couldn't work out the next step with that (peek or such) for this problem, b&lt;/P&gt;
&lt;P&gt;I have sorted the example data attached by batch, just so you can see the same batch for both movement types (if it has been booked out).&lt;/P&gt;
&lt;P&gt;Thanks in advance, again.&lt;/P&gt;
&lt;P&gt;Regards Daryn&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Mar 2023 15:31:23 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Load-earliest-date-but-when-another-field-value-matches-a/m-p/2046286#M86063</guid>
      <dc:creator>Daryn</dc:creator>
      <dc:date>2023-03-07T15:31:23Z</dc:date>
    </item>
    <item>
      <title>Re: Load earliest date but when another field value matches a specific value.</title>
      <link>https://community.qlik.com/t5/App-Development/Load-earliest-date-but-when-another-field-value-matches-a/m-p/2047439#M86148</link>
      <description>&lt;P&gt;Hi Daryn,&lt;/P&gt;
&lt;P&gt;If you only need the batch number and the dates:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;MvT281:
LOAD  
     [Entry Date]	as DATE281,
     Batch
FROM
[C:\Users\xxx\Downloads\Vehicles.xlsx]
(ooxml, embedded labels, table is Vehicles)
where MvT = 281;

MvT501:
OUTER JOIN (MvT281) LOAD  
     [Entry Date]	as DATE501,
     Batch
FROM
[C:\Users\xxx\Downloads\Vehicles.xlsx]
(ooxml, embedded labels, table is Vehicles)
where MvT = 501;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope it helps!&lt;/P&gt;</description>
      <pubDate>Thu, 09 Mar 2023 14:23:12 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Load-earliest-date-but-when-another-field-value-matches-a/m-p/2047439#M86148</guid>
      <dc:creator>Marijn</dc:creator>
      <dc:date>2023-03-09T14:23:12Z</dc:date>
    </item>
    <item>
      <title>Re: Load earliest date but when another field value matches a specific value.</title>
      <link>https://community.qlik.com/t5/App-Development/Load-earliest-date-but-when-another-field-value-matches-a/m-p/2047446#M86151</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;Marijn,&lt;BR /&gt;I will have a look later today or tomorrow asap and come back with an update/mark as solution etc.&lt;/P&gt;
&lt;P&gt;Appreciate the time you have taken,&lt;/P&gt;
&lt;P&gt;Regards Daryn&lt;/P&gt;</description>
      <pubDate>Thu, 09 Mar 2023 14:31:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Load-earliest-date-but-when-another-field-value-matches-a/m-p/2047446#M86151</guid>
      <dc:creator>Daryn</dc:creator>
      <dc:date>2023-03-09T14:31:42Z</dc:date>
    </item>
    <item>
      <title>Re: Load earliest date but when another field value matches a specific value.</title>
      <link>https://community.qlik.com/t5/App-Development/Load-earliest-date-but-when-another-field-value-matches-a/m-p/2047521#M86159</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;SPAN&gt;Marijn,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Is there a way to set your script suggestion to only load the first date of either 281 or 501 (if it finds more than one of the same type), example the same batch number has been booked in twice on different dates (booked in, then out, then back in for warranty work) so has two entry dates with MvT 501 (but I only need the first).....&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Hope that makes sense. I tried with Min ([Entry Date])&amp;nbsp; in both tables, but it just errored on load.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Again, appreciated.&lt;/P&gt;
&lt;P&gt;Daryn&lt;/P&gt;
&lt;P&gt;An example is this batch below, I want to calculate from the earliest booked in(581) of&amp;nbsp; 04.11.2022 to the out (282) 26.01.2023 this should give me 83 days but the chart is -6 (the difference between the second 581 date and the 281.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Daryn_0-1678461485953.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/102513i17F165AF084E9EC3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Daryn_0-1678461485953.png" alt="Daryn_0-1678461485953.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Daryn_1-1678461513320.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/102514i46007D723119EB4F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Daryn_1-1678461513320.png" alt="Daryn_1-1678461513320.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&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="Daryn_2-1678461552292.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/102515i57D450ACC63DDC16/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Daryn_2-1678461552292.png" alt="Daryn_2-1678461552292.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2023 15:19:28 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Load-earliest-date-but-when-another-field-value-matches-a/m-p/2047521#M86159</guid>
      <dc:creator>Daryn</dc:creator>
      <dc:date>2023-03-10T15:19:28Z</dc:date>
    </item>
    <item>
      <title>Re: Load earliest date but when another field value matches a specific value.</title>
      <link>https://community.qlik.com/t5/App-Development/Load-earliest-date-but-when-another-field-value-matches-a/m-p/2048375#M86206</link>
      <description>&lt;P&gt;I think like this:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;MvT281_load:
LOAD  
     [Entry Date]	as DATE281,
     Batch
FROM
[C:\Users\marijn\Downloads\Vehicles.xlsx]
(ooxml, embedded labels, table is Vehicles)
where MvT = 281;

main:
NOCONCATENATE LOAD FirstValue(DATE281)	AS DATE281,
	Batch
resident MvT281_load
group by Batch
order by DATE281 asc
; 

drop table MvT281_load;
//exit script;

MvT501_load:
LOAD  
     [Entry Date]	as DATE501,
     Batch
FROM
[C:\Users\marijn\Downloads\Vehicles.xlsx]
(ooxml, embedded labels, table is Vehicles)
where MvT = 501;


outer join (main)
LOAD FirstValue(DATE501) AS DATE501,
	Batch
resident MvT501_load
group by Batch
order by DATE501 asc
;

drop table MvT501_load;&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 13 Mar 2023 09:49:26 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Load-earliest-date-but-when-another-field-value-matches-a/m-p/2048375#M86206</guid>
      <dc:creator>Marijn</dc:creator>
      <dc:date>2023-03-13T09:49:26Z</dc:date>
    </item>
    <item>
      <title>Re: Load earliest date but when another field value matches a specific value.</title>
      <link>https://community.qlik.com/t5/App-Development/Load-earliest-date-but-when-another-field-value-matches-a/m-p/2048389#M86209</link>
      <description>&lt;P&gt;Marijn,&lt;/P&gt;
&lt;P&gt;Again really appreciate your time and knowledge with this, I should be free to test this, this afternoon.&amp;nbsp; &lt;span class="lia-unicode-emoji" title=":thumbs_up:"&gt;👍&lt;/span&gt;&amp;nbsp; &lt;span class="lia-unicode-emoji" title=":crossed_fingers:"&gt;🤞&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Kindest Regards,&lt;/P&gt;
&lt;P&gt;Daryn&lt;/P&gt;</description>
      <pubDate>Mon, 13 Mar 2023 10:06:45 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Load-earliest-date-but-when-another-field-value-matches-a/m-p/2048389#M86209</guid>
      <dc:creator>Daryn</dc:creator>
      <dc:date>2023-03-13T10:06:45Z</dc:date>
    </item>
    <item>
      <title>Re: Load earliest date but when another field value matches a specific value.</title>
      <link>https://community.qlik.com/t5/App-Development/Load-earliest-date-but-when-another-field-value-matches-a/m-p/2048979#M86234</link>
      <description>&lt;P&gt;Marijn,&lt;/P&gt;
&lt;P&gt;I have applied your load script and have no errors. But is still doesn't appear to apply the first date (in the example two dates for type '501'.&lt;/P&gt;
&lt;P&gt;In my understanding of your script it should, but the entry date 04.11.2022 is being written to DATE501 as 01.02.2023 (the second date of type '501').&lt;/P&gt;
&lt;P&gt;I am sorry to ask if you have any further ideas?&lt;/P&gt;
&lt;P&gt;Thank you once again.&lt;/P&gt;
&lt;P&gt;Regards, Daryn&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Daryn_0-1678798194199.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/102707i3FA5D1898B74DBB3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Daryn_0-1678798194199.png" alt="Daryn_0-1678798194199.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Mar 2023 12:50:29 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Load-earliest-date-but-when-another-field-value-matches-a/m-p/2048979#M86234</guid>
      <dc:creator>Daryn</dc:creator>
      <dc:date>2023-03-14T12:50:29Z</dc:date>
    </item>
    <item>
      <title>Re: Load earliest date but when another field value matches a specific value.</title>
      <link>https://community.qlik.com/t5/App-Development/Load-earliest-date-but-when-another-field-value-matches-a/m-p/2048997#M86237</link>
      <description>&lt;P&gt;Yes, the date was misinterpreted as something other than a date by Qlik. I've added the date# so it's interpreted correctly and then it can be ordered (with the order by) correctly. See here:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;MvT281_load:
LOAD  
     floor(date#([Entry Date],'DD.MM.YYYY'))	as DATE281,
     Batch
FROM
[C:\Users\marijn\Downloads\Vehicles.xlsx]
(ooxml, embedded labels, table is Vehicles)
where MvT = 281;

main:
NOCONCATENATE LOAD FirstValue(DATE281)	AS DATE281,
	Batch
resident MvT281_load
group by Batch
order by DATE281 asc
; 

drop table MvT281_load;

MvT501_load:
LOAD  
     floor(date#([Entry Date],'DD.MM.YYYY'))	as DATE501,
     Batch
FROM
[C:\Users\marijn\Downloads\Vehicles.xlsx]
(ooxml, embedded labels, table is Vehicles)
where MvT = 501;


outer join (main)
LOAD FirstValue(DATE501) AS DATE501,
	Batch
resident MvT501_load
group by Batch
order by DATE501 asc
;

drop table MvT501_load;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Be aware that I also used a floor() to make the date into a number. If you put this into a table, make sure that your change this number to a date again with the number format settings.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Mar 2023 13:16:53 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Load-earliest-date-but-when-another-field-value-matches-a/m-p/2048997#M86237</guid>
      <dc:creator>Marijn</dc:creator>
      <dc:date>2023-03-14T13:16:53Z</dc:date>
    </item>
    <item>
      <title>Re: Load earliest date but when another field value matches a specific value.</title>
      <link>https://community.qlik.com/t5/App-Development/Load-earliest-date-but-when-another-field-value-matches-a/m-p/2049423#M86255</link>
      <description>&lt;P&gt;Marijn,&lt;/P&gt;
&lt;P&gt;I applied your new loadscript (and thank you for the comment about floor).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Unfortunately I still don't get the expected first date, which makes no sense to me!&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Daryn_0-1678875312827.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/102807i7A7ECE2AFE488842/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Daryn_0-1678875312827.png" alt="Daryn_0-1678875312827.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Apologies, I am sure I have given you a headache as well as myself.&lt;/P&gt;
&lt;P&gt;Kindest regards&lt;/P&gt;
&lt;P&gt;Daryn&lt;/P&gt;</description>
      <pubDate>Wed, 15 Mar 2023 10:16:09 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Load-earliest-date-but-when-another-field-value-matches-a/m-p/2049423#M86255</guid>
      <dc:creator>Daryn</dc:creator>
      <dc:date>2023-03-15T10:16:09Z</dc:date>
    </item>
    <item>
      <title>Re: Load earliest date but when another field value matches a specific value.</title>
      <link>https://community.qlik.com/t5/App-Development/Load-earliest-date-but-when-another-field-value-matches-a/m-p/2049438#M86256</link>
      <description>&lt;P&gt;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/135319"&gt;@Daryn&lt;/a&gt; could you give me that dataset? I don't have the data entries I see in your example. It's strange because it works on my computer (I manually added the row to the data), so I'd like to test with that set if possible.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Mar 2023 10:46:48 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Load-earliest-date-but-when-another-field-value-matches-a/m-p/2049438#M86256</guid>
      <dc:creator>Marijn</dc:creator>
      <dc:date>2023-03-15T10:46:48Z</dc:date>
    </item>
    <item>
      <title>Re: Load earliest date but when another field value matches a specific value.</title>
      <link>https://community.qlik.com/t5/App-Development/Load-earliest-date-but-when-another-field-value-matches-a/m-p/2049443#M86257</link>
      <description>&lt;P&gt;Again, can't thank you enough for your time with this.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Mar 2023 11:01:27 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Load-earliest-date-but-when-another-field-value-matches-a/m-p/2049443#M86257</guid>
      <dc:creator>Daryn</dc:creator>
      <dc:date>2023-03-15T11:01:27Z</dc:date>
    </item>
    <item>
      <title>Re: Load earliest date but when another field value matches a specific value.</title>
      <link>https://community.qlik.com/t5/App-Development/Load-earliest-date-but-when-another-field-value-matches-a/m-p/2049889#M86296</link>
      <description>&lt;P&gt;Hi Daryn,&lt;/P&gt;
&lt;P&gt;Also with the updated dataset I get the correct results, can you give me the complete script you're using? I see that there are fields in your example that are not used in my script, so maybe the group by or order by is changed with your additions?&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2023 08:12:10 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Load-earliest-date-but-when-another-field-value-matches-a/m-p/2049889#M86296</guid>
      <dc:creator>Marijn</dc:creator>
      <dc:date>2023-03-16T08:12:10Z</dc:date>
    </item>
    <item>
      <title>Re: Load earliest date but when another field value matches a specific value.</title>
      <link>https://community.qlik.com/t5/App-Development/Load-earliest-date-but-when-another-field-value-matches-a/m-p/2049896#M86297</link>
      <description>&lt;P&gt;Hi Marijn,&lt;/P&gt;
&lt;P&gt;Thank you for your reply. This prompted me to check and find an error in my loadscript (pointing to a previous copy of Vehicles.xlsx (it was looking at&amp;nbsp;Vehicles_.xlsx)! An altered version I had tried some testing with.&lt;/P&gt;
&lt;P&gt;Sorry to have not spotted this before and saved your last responses.&lt;/P&gt;
&lt;P&gt;I would like to say a huge thank you again,&amp;nbsp; for your time and knowledge, I have leant a lot from this.&lt;/P&gt;
&lt;P&gt;Really appreciated.&lt;/P&gt;
&lt;P&gt;Kindest regards,&lt;/P&gt;
&lt;P&gt;Daryn&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2023 08:19:21 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Load-earliest-date-but-when-another-field-value-matches-a/m-p/2049896#M86297</guid>
      <dc:creator>Daryn</dc:creator>
      <dc:date>2023-03-16T08:19:21Z</dc:date>
    </item>
  </channel>
</rss>

