<?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 Complex Join Query - Multiple Conditions/Calculations and Dates in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Complex-Join-Query-Multiple-Conditions-Calculations-and-Dates/m-p/1564968#M62944</link>
    <description>&lt;P&gt;Hello Fellow Qlik Users!&lt;/P&gt;&lt;P&gt;I'm hoping one of you more learned community members can help run me through how I would perform a complex join on two tables based on multiple conditions.&lt;/P&gt;&lt;P&gt;I have two separate SQL queries (from the same database table) generating the sample dummy output of the following (or excel attached) 2 tables, which is defined by grouping project milestone names.&lt;/P&gt;&lt;P&gt;Project Lifecycle Table:&lt;/P&gt;&lt;P&gt;Project Number, Project Version, Milestone Name, Milestone Sequence, Start Date, End Date, Total Duration, Milestone Status&lt;BR /&gt;123456, 1, Project Creation, 1, 1/01/2019, 20/01/2019, 19, Completed&lt;BR /&gt;123456, 1, Customer Invoicing, 6, 20/01/2019, null, 74, WIP&lt;BR /&gt;123456, 2, Resource Confirmation, 9, 15/02/2019, 5/03/2019, 18, Completed&lt;BR /&gt;123456, 2, Construction, 15, 5/03/2019, null, 30, WIP&lt;BR /&gt;987654, 1, Project Creation, 1, 2/01/2019, 7/01/2019, 92, Completed&lt;BR /&gt;987654, 1, Customer Invoicing, 4, 7/01/2019, 31/01/2019, 87, Completed&lt;BR /&gt;987654, 1, Resource Planning, 7, 31/01/2019, 2/02/2019, 63,Completed&lt;BR /&gt;987654, 2, Customer Invoicing, 14, 2/02/2019, null, 61, WIP&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Project Hold Table: (where a single or multiple 'Hold' milestone can occur anywhere during Project Lifecycle of a Project Number ie. can be seen as 'milestone hold flags')&lt;/P&gt;&lt;P&gt;Project Number, Hold Type, Milestone Name, Milestone Sequence, Start Date, End Date, Total Duration&lt;BR /&gt;123456, External, Customer, 7, 25/01/2019, 10/02/2019, 16&lt;BR /&gt;123456, Internal, Engineering, 16, 7/03/2019, 15/03/2019, 8&lt;BR /&gt;123456, Internal, Fleet, 17, 8/03/2019, 10/03/2019, 2&lt;BR /&gt;987654, External, Customer, 5, 9/01/2019, 11/01/2019, 2&lt;BR /&gt;987654, External, Customer, 6, 15/01/2019, 20/01/2019, 5&lt;BR /&gt;987654, External, Customer, 15, 5/02/2019, null, 58&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I've attempted to use nested/correlated subqueries in SQL (as I don't have access to create temporary tables, or to create a procedure by PL/SQL) however I'm thinking there would be a more optimal way to create an output table in the data load editor of Qlik Sense.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Requirements of Output Table / Join :&lt;BR /&gt;- 'Milestone Status' to be calculated on most recent Milestone by Project Number (ie. End Date to be defined as the start of the next milestone by project number)&lt;BR /&gt;- Multiple Hold Milestones by Hold Type to be grouped/rolled up by Project Number and looking up the difference of the start/end date by Milestone in the Project Lifecycle&lt;BR /&gt;- Output to transpose hold details of completed hold&lt;BR /&gt;- Output to transpose hold details of hold in progress (ie. where there is no end date, use system date to calculate date difference as duration)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Required Output Table:&lt;/P&gt;&lt;P&gt;Project Number, Project Version, Milestone Name, Milestone Sequence, Start Date, End Date, Total Duration, Milestone Status, Internal Hold Status, Internal Hold Duration, External Hold Status, External Hold Duration&lt;BR /&gt;123456, 1, Project Creation, 1, 1/01/2019, 20/01/2019, 19, Completed, null, null, null, null&lt;BR /&gt;123456, 1, Customer Invoicing, 6, 20/01/2019, null, 74, Completed, Completed, 16, null, null&lt;BR /&gt;123456, 2, Resource Confirmation, 9, 15/02/2019, 5/03/2019, 18, Completed, null, null, null, null&lt;BR /&gt;123456, 2, Construction, 15, 5/03/2019, null, 30, WIP, WIP, 10, null, null&lt;BR /&gt;987654, 1, Project Creation, 1, 2/01/2019, 7/01/2019, 92, Completed, null, null, null, null&lt;BR /&gt;987654, 1, Customer Invoicing, 4, 7/01/2019, 31/01/2019, 87, Completed, null, null, Completed, 7&lt;BR /&gt;987654, 1, Resource Planning, 7, 31/01/2019, 2/02/2019, 63, Completed, null, null, null, null&lt;BR /&gt;987654, 2, Customer Invoicing, 14, 2/02/2019, null, 61, WIP, null, null, WIP, 58&lt;/P&gt;&lt;P&gt;The data set I'm working with consists of hundreds of thousands of rows which adds to the challenge &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Thank you all in advance for your help and guidance.&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Phil&lt;/P&gt;</description>
    <pubDate>Fri, 02 Apr 2021 07:53:11 GMT</pubDate>
    <dc:creator>parky</dc:creator>
    <dc:date>2021-04-02T07:53:11Z</dc:date>
    <item>
      <title>Complex Join Query - Multiple Conditions/Calculations and Dates</title>
      <link>https://community.qlik.com/t5/App-Development/Complex-Join-Query-Multiple-Conditions-Calculations-and-Dates/m-p/1564968#M62944</link>
      <description>&lt;P&gt;Hello Fellow Qlik Users!&lt;/P&gt;&lt;P&gt;I'm hoping one of you more learned community members can help run me through how I would perform a complex join on two tables based on multiple conditions.&lt;/P&gt;&lt;P&gt;I have two separate SQL queries (from the same database table) generating the sample dummy output of the following (or excel attached) 2 tables, which is defined by grouping project milestone names.&lt;/P&gt;&lt;P&gt;Project Lifecycle Table:&lt;/P&gt;&lt;P&gt;Project Number, Project Version, Milestone Name, Milestone Sequence, Start Date, End Date, Total Duration, Milestone Status&lt;BR /&gt;123456, 1, Project Creation, 1, 1/01/2019, 20/01/2019, 19, Completed&lt;BR /&gt;123456, 1, Customer Invoicing, 6, 20/01/2019, null, 74, WIP&lt;BR /&gt;123456, 2, Resource Confirmation, 9, 15/02/2019, 5/03/2019, 18, Completed&lt;BR /&gt;123456, 2, Construction, 15, 5/03/2019, null, 30, WIP&lt;BR /&gt;987654, 1, Project Creation, 1, 2/01/2019, 7/01/2019, 92, Completed&lt;BR /&gt;987654, 1, Customer Invoicing, 4, 7/01/2019, 31/01/2019, 87, Completed&lt;BR /&gt;987654, 1, Resource Planning, 7, 31/01/2019, 2/02/2019, 63,Completed&lt;BR /&gt;987654, 2, Customer Invoicing, 14, 2/02/2019, null, 61, WIP&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Project Hold Table: (where a single or multiple 'Hold' milestone can occur anywhere during Project Lifecycle of a Project Number ie. can be seen as 'milestone hold flags')&lt;/P&gt;&lt;P&gt;Project Number, Hold Type, Milestone Name, Milestone Sequence, Start Date, End Date, Total Duration&lt;BR /&gt;123456, External, Customer, 7, 25/01/2019, 10/02/2019, 16&lt;BR /&gt;123456, Internal, Engineering, 16, 7/03/2019, 15/03/2019, 8&lt;BR /&gt;123456, Internal, Fleet, 17, 8/03/2019, 10/03/2019, 2&lt;BR /&gt;987654, External, Customer, 5, 9/01/2019, 11/01/2019, 2&lt;BR /&gt;987654, External, Customer, 6, 15/01/2019, 20/01/2019, 5&lt;BR /&gt;987654, External, Customer, 15, 5/02/2019, null, 58&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I've attempted to use nested/correlated subqueries in SQL (as I don't have access to create temporary tables, or to create a procedure by PL/SQL) however I'm thinking there would be a more optimal way to create an output table in the data load editor of Qlik Sense.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Requirements of Output Table / Join :&lt;BR /&gt;- 'Milestone Status' to be calculated on most recent Milestone by Project Number (ie. End Date to be defined as the start of the next milestone by project number)&lt;BR /&gt;- Multiple Hold Milestones by Hold Type to be grouped/rolled up by Project Number and looking up the difference of the start/end date by Milestone in the Project Lifecycle&lt;BR /&gt;- Output to transpose hold details of completed hold&lt;BR /&gt;- Output to transpose hold details of hold in progress (ie. where there is no end date, use system date to calculate date difference as duration)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Required Output Table:&lt;/P&gt;&lt;P&gt;Project Number, Project Version, Milestone Name, Milestone Sequence, Start Date, End Date, Total Duration, Milestone Status, Internal Hold Status, Internal Hold Duration, External Hold Status, External Hold Duration&lt;BR /&gt;123456, 1, Project Creation, 1, 1/01/2019, 20/01/2019, 19, Completed, null, null, null, null&lt;BR /&gt;123456, 1, Customer Invoicing, 6, 20/01/2019, null, 74, Completed, Completed, 16, null, null&lt;BR /&gt;123456, 2, Resource Confirmation, 9, 15/02/2019, 5/03/2019, 18, Completed, null, null, null, null&lt;BR /&gt;123456, 2, Construction, 15, 5/03/2019, null, 30, WIP, WIP, 10, null, null&lt;BR /&gt;987654, 1, Project Creation, 1, 2/01/2019, 7/01/2019, 92, Completed, null, null, null, null&lt;BR /&gt;987654, 1, Customer Invoicing, 4, 7/01/2019, 31/01/2019, 87, Completed, null, null, Completed, 7&lt;BR /&gt;987654, 1, Resource Planning, 7, 31/01/2019, 2/02/2019, 63, Completed, null, null, null, null&lt;BR /&gt;987654, 2, Customer Invoicing, 14, 2/02/2019, null, 61, WIP, null, null, WIP, 58&lt;/P&gt;&lt;P&gt;The data set I'm working with consists of hundreds of thousands of rows which adds to the challenge &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Thank you all in advance for your help and guidance.&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Phil&lt;/P&gt;</description>
      <pubDate>Fri, 02 Apr 2021 07:53:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Complex-Join-Query-Multiple-Conditions-Calculations-and-Dates/m-p/1564968#M62944</guid>
      <dc:creator>parky</dc:creator>
      <dc:date>2021-04-02T07:53:11Z</dc:date>
    </item>
  </channel>
</rss>

