<?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: Calculating Outbound/Inbound Flight Times for Connections in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Calculating-Outbound-Inbound-Flight-Times-for-Connections/m-p/1822565#M67449</link>
    <description>&lt;P&gt;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/336"&gt;@Kushal_Chawda&lt;/a&gt;&amp;nbsp; rock on.&amp;nbsp; this appears to work as I expected.&amp;nbsp; thank you very much for your help!&lt;/P&gt;</description>
    <pubDate>Thu, 15 Jul 2021 21:46:05 GMT</pubDate>
    <dc:creator>carlcimino</dc:creator>
    <dc:date>2021-07-15T21:46:05Z</dc:date>
    <item>
      <title>Calculating Outbound/Inbound Flight Times for Connections</title>
      <link>https://community.qlik.com/t5/App-Development/Calculating-Outbound-Inbound-Flight-Times-for-Connections/m-p/1820791#M67284</link>
      <description>&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;Hello I am trying to calculate the flight duration for the outbound portion of the trip and the inbound portion of the trip.&amp;nbsp; A trip can have multiple segments on the oubound and inbound portions.&amp;nbsp; I've attached some sample data and in it there is a sequence number for each segment and also a field to show if a segment is a connection on the trip.&amp;nbsp; &amp;nbsp;In the example below I am looking to calculate the leg duration (green column).&amp;nbsp; I know I have to use a combination of the Trip Key, Flight Sequence and Connection and then sum the Segment Duration but not sure how to set that up with set analysis.&amp;nbsp;&amp;nbsp;How would one go about doing this?&amp;nbsp; Is this an aggr situation? Do I need to do any additional data modeling work to facilitate?&amp;nbsp; Any suggestions would be appreciated.&lt;/FONT&gt;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;Trip Key&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;Flight Sequence&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;Departure Airport&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;Arrival Airport&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;Connection&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;Segment Duration&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;Leg Duration&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;20210622AXU7830283861&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;1&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;BHM&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;ATL&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;Y&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;1.2&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;20210622AXU7830283861&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;2&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;ATL&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;CRW&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;1.3&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;2.5&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;20210622AXU7830283861&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;3&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;CRW&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;ATL&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;Y&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;1.5&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;20210622AXU7830283861&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;4&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;ATL&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;BHM&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;0.9&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;2.4&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Nov 2024 23:58:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Calculating-Outbound-Inbound-Flight-Times-for-Connections/m-p/1820791#M67284</guid>
      <dc:creator>carlcimino</dc:creator>
      <dc:date>2024-11-15T23:58:25Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating Outbound/Inbound Flight Times for Connections</title>
      <link>https://community.qlik.com/t5/App-Development/Calculating-Outbound-Inbound-Flight-Times-for-Connections/m-p/1820972#M67301</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;It seems to me that you need a way of indicating that the leg is outbound or inbound, then you can simply add up the leg duration of each trip key-outbound/inbound combination&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jul 2021 10:37:53 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Calculating-Outbound-Inbound-Flight-Times-for-Connections/m-p/1820972#M67301</guid>
      <dc:creator>rbartley</dc:creator>
      <dc:date>2021-07-09T10:37:53Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating Outbound/Inbound Flight Times for Connections</title>
      <link>https://community.qlik.com/t5/App-Development/Calculating-Outbound-Inbound-Flight-Times-for-Connections/m-p/1821015#M67306</link>
      <description>&lt;P&gt;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/16061"&gt;@carlcimino&lt;/a&gt;&amp;nbsp; you might need to do scripting to do this&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;Data:
LOAD [Trip Key], 
     [Flight Sequence], 
     [Departure Airport], 
     [Arrival Airport], 
     Connection, 
     [Segment Duration]
FROM
[Sample Trip Data.xlsx]
(ooxml, embedded labels, table is Data);

T1:
LOAD *,
     if([Trip Key]&amp;lt;&amp;gt;Previous([Trip Key]) or ([Trip Key]=Previous([Trip Key]) and lower(trim(Connection))='y' and previous(lower(trim(Connection)))&amp;lt;&amp;gt;'y'), 
     [Segment Duration], RangeSum([Segment Duration],Peek('Segment_lag_temp')))  as Segment_lag_temp
Resident Data
Order by [Trip Key], [Flight Sequence];

DROP Table Data;

Final:
LOAD *,
     if(lower(trim(Connection))='y',0,Segment_lag_temp) as Segment_lag
Resident T1;

DROP Table T1;

DROP Field Segment_lag_temp;&lt;/LI-CODE&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="Screenshot 2021-07-09 133740.png" style="width: 760px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/58329i2EEBFA17EB6EE76A/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2021-07-09 133740.png" alt="Screenshot 2021-07-09 133740.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jul 2021 12:38:17 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Calculating-Outbound-Inbound-Flight-Times-for-Connections/m-p/1821015#M67306</guid>
      <dc:creator>Kushal_Chawda</dc:creator>
      <dc:date>2021-07-09T12:38:17Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating Outbound/Inbound Flight Times for Connections</title>
      <link>https://community.qlik.com/t5/App-Development/Calculating-Outbound-Inbound-Flight-Times-for-Connections/m-p/1821128#M67310</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/336"&gt;@Kushal_Chawda&lt;/a&gt;&amp;nbsp;This looks to be almost what I was expecting.&amp;nbsp; Where it does not look as expected is when there are no connections at all like the trip below which is just a there and back.&amp;nbsp; &amp;nbsp;In this case the Segment_Lag should be equal to the Segment Duration.&amp;nbsp; But that would have to be an extra peek to see if there are any Connection = Y at all right?&amp;nbsp; Where would that go in the T1 section or the Final?&amp;nbsp; Or would you another step in between?&amp;nbsp; Thanks again I appreciate the help.&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Trip Key&lt;/TD&gt;&lt;TD&gt;Flight Sequence&lt;/TD&gt;&lt;TD&gt;Departure Airport&lt;/TD&gt;&lt;TD&gt;Arrival Airport&lt;/TD&gt;&lt;TD&gt;Connection&lt;/TD&gt;&lt;TD&gt;Segment Duration&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;20210621AXM1100118806391&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;MTY&lt;/TD&gt;&lt;TD&gt;MEX&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;1.6&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;20210621AXM1100118806391&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;MEX&lt;/TD&gt;&lt;TD&gt;MTY&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;1.8&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Fri, 09 Jul 2021 18:06:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Calculating-Outbound-Inbound-Flight-Times-for-Connections/m-p/1821128#M67310</guid>
      <dc:creator>carlcimino</dc:creator>
      <dc:date>2021-07-09T18:06:42Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating Outbound/Inbound Flight Times for Connections</title>
      <link>https://community.qlik.com/t5/App-Development/Calculating-Outbound-Inbound-Flight-Times-for-Connections/m-p/1821208#M67319</link>
      <description>&lt;P&gt;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/16061"&gt;@carlcimino&lt;/a&gt;&amp;nbsp; try this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;Data:
LOAD [Trip Key], 
     [Flight Sequence], 
     [Departure Airport], 
     [Arrival Airport], 
     Connection, 
     [Segment Duration]
FROM
[Sample Trip Data.xlsx]
(ooxml, embedded labels, table is Data);


T1:
NoConcatenate
LOAD *,

     if([Flight Sequence]=1 and len(trim(Connection))=0,null(),
     if(lower(trim(Connection))='y',RangeSum(1,Peek('connection_group')),
     if(len(trim(Connection))=0,Peek('connection_group'),
     ))) as connection_group,
    
     if(lower(trim(Connection))='y',1,
     RangeSum(1,Peek('connection_sequence'))) as connection_sequence,
     
     if([Trip Key]&amp;lt;&amp;gt;Previous([Trip Key]) or ([Trip Key]=Previous([Trip Key]) and lower(trim(Connection))='y' and previous(lower(trim(Connection)))&amp;lt;&amp;gt;'y'), 
     [Segment Duration], RangeSum([Segment Duration],Peek('Segment_lag_temp')))  as Segment_lag_temp
Resident Data
Order by [Trip Key], [Flight Sequence];

Left Join(T1)
LOAD [Trip Key],
      connection_group,
      max(connection_sequence) as Max_connection_sequence
Resident T1
Group by [Trip Key],
      connection_group;

DROP Table Data;

Final:
LOAD *,
     if(Max_connection_sequence=connection_sequence and lower(trim(Connection))&amp;lt;&amp;gt;'y' ,Segment_lag_temp,
     if(len(trim(connection_group))=0,[Segment Duration],0)) as Segment_lag
Resident T1;

DROP Table T1;

DROP Fields Segment_lag_temp,Max_connection_sequence,connection_sequence,connection_group;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&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="Kushal_Chawda_0-1625927975566.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/58379i8DF3969BE43578B1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Kushal_Chawda_0-1625927975566.png" alt="Kushal_Chawda_0-1625927975566.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 10 Jul 2021 14:51:40 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Calculating-Outbound-Inbound-Flight-Times-for-Connections/m-p/1821208#M67319</guid>
      <dc:creator>Kushal_Chawda</dc:creator>
      <dc:date>2021-07-10T14:51:40Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating Outbound/Inbound Flight Times for Connections</title>
      <link>https://community.qlik.com/t5/App-Development/Calculating-Outbound-Inbound-Flight-Times-for-Connections/m-p/1822565#M67449</link>
      <description>&lt;P&gt;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/336"&gt;@Kushal_Chawda&lt;/a&gt;&amp;nbsp; rock on.&amp;nbsp; this appears to work as I expected.&amp;nbsp; thank you very much for your help!&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jul 2021 21:46:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Calculating-Outbound-Inbound-Flight-Times-for-Connections/m-p/1822565#M67449</guid>
      <dc:creator>carlcimino</dc:creator>
      <dc:date>2021-07-15T21:46:05Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating Outbound/Inbound Flight Times for Connections</title>
      <link>https://community.qlik.com/t5/App-Development/Calculating-Outbound-Inbound-Flight-Times-for-Connections/m-p/1822572#M67450</link>
      <description>&lt;P&gt;Glad that it worked&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jul 2021 23:21:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Calculating-Outbound-Inbound-Flight-Times-for-Connections/m-p/1822572#M67450</guid>
      <dc:creator>Kushal_Chawda</dc:creator>
      <dc:date>2021-07-15T23:21:51Z</dc:date>
    </item>
  </channel>
</rss>

