<?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: Incremental load with multiple delete flags in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Incremental-load-with-multiple-delete-flags/m-p/2548113#M110135</link>
    <description>&lt;P&gt;Incorrect response. In the incremental load logic, I want customers that are active and orders that are active. So if&amp;nbsp;&lt;SPAN&gt;IS_ORDER_DELETED changes from 0 to 1, then i still need all the customer data to display and null for all order related fields which i am not able to achieve with this script&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 29 Apr 2026 21:16:06 GMT</pubDate>
    <dc:creator>lost_rabbit</dc:creator>
    <dc:date>2026-04-29T21:16:06Z</dc:date>
    <item>
      <title>Incremental load with multiple delete flags</title>
      <link>https://community.qlik.com/t5/App-Development/Incremental-load-with-multiple-delete-flags/m-p/2548108#M110133</link>
      <description>&lt;P&gt;I have a data load requirement involving two tables:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;STRONG&gt;Customers (Primary Key - Id)&lt;/STRONG&gt;&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;Orders&amp;nbsp; (Primary Key - Id)&lt;/STRONG&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;My goal is to load all active customers from Customers and their matching active records from Orders. If there are no orders, then those fields should be null in data set (Simple left join condition)&lt;/P&gt;&lt;P&gt;Challenge:&lt;/P&gt;&lt;P&gt;The difficulty I’m facing is correctly handling&amp;nbsp; two deletion flags while still maintaining an incremental load approach.&lt;/P&gt;&lt;P&gt;Kindly help with below script&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;IF Len('$(QVD_PATH)') = 0 THEN

Final:
SQL SELECT 
    A.ID,
    A.NAME,
    B.RATE,
    A.IS_CUSTOMER_DELETED,
    B.IS_ORDER_DELETED,
    GREATEST(A.LAST_UPDATE_DATE, B.LAST_UPDATE_DATE) AS LAST_UPDATE_DATE
FROM Customers A
LEFT JOIN Orders B ON A.ID = B.ID AND B.IS_ORDER_DELETED = 0
WHERE A.IS_CUSTOMER_DELETED = 0;

Call StoreAndDrop('Final');

ELSE

Last_Update_Date:
LOAD Timestamp(Max(LAST_UPDATE_DATE)) as Max_LAST_UPDATE_DATE
FROM [$(QVD_PATH)](qvd);

LET vMaxDate = Peek('Max_LAST_UPDATE_DATE', 0, 'Last_Update_Date');

Temp:
SQL SELECT 
    A.ID,
    A.NAME,
    B.RATE,
    A.IS_CUSTOMER_DELETED,
    B.IS_ORDER_DELETED,
    GREATEST(A.LAST_UPDATE_DATE, B.LAST_UPDATE_DATE) AS LAST_UPDATE_DATE
FROM Customers A
LEFT JOIN Orders B ON A.ID = B.ID 
WHERE  GREATEST(A.LAST_UPDATE_DATE, B.LAST_UPDATE_DATE)&amp;gt; '$(vMaxDate)'

Concatenate(Temp)
LOAD * 
FROM [$(QVD_PATH)](qvd) 
where NOT Exists(ID);

Final:
NoConcatenate
LOAD *
RESIDENT Temp
WHERE IS_CUSTOMER_DELETED = 0 AND IS_ORDER_DELETED = 0;

Call StoreAndDrop('Final');

END IF;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Apr 2026 20:54:44 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Incremental-load-with-multiple-delete-flags/m-p/2548108#M110133</guid>
      <dc:creator>lost_rabbit</dc:creator>
      <dc:date>2026-04-29T20:54:44Z</dc:date>
    </item>
    <item>
      <title>Re: Incremental load with multiple delete flags</title>
      <link>https://community.qlik.com/t5/App-Development/Incremental-load-with-multiple-delete-flags/m-p/2548109#M110134</link>
      <description>&lt;P&gt;This Qlik script implements a soft-delete mechanism for incremental QVD loading, filtering out records marked deleted in source SQL tables. It handles full loads when QVD doesn't exist and incremental updates by checking IS_CUSTOMER_DELETED and IS_ORDER_DELETED flags, ultimately storing clean records into a QVD.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Code Breakdown:&lt;/STRONG&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;STRONG&gt;Initialization:&lt;/STRONG&gt; The IF Len('$(QVD_PATH)') = 0 clause detects if this is the first load (no existing QVD), executing a full initial load.&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;Incremental Logic (ELSE):&lt;/STRONG&gt; Finds the latest LAST_UPDATE_DATE from the existing QVD, then queries the SQL database for records modified after that date.&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;Deletion Handling:&lt;/STRONG&gt; In both scenarios, the script filters records (WHERE IS_CUSTOMER_DELETED = 0 AND IS_ORDER_DELETED = 0) to ensure soft-deleted records in source tables are excluded from the final QVD.&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;Update Mechanism:&lt;/STRONG&gt; Call StoreAndDrop('Final') assumes a routine that stores the Final table and drops it to free memory.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This approach is efficient for large datasets because it only processes new or updated records rather than reloading the entire dataset every time.&lt;BR /&gt;&lt;BR /&gt;This should achieve your goal.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Apr 2026 20:21:47 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Incremental-load-with-multiple-delete-flags/m-p/2548109#M110134</guid>
      <dc:creator>Greg_Taffer</dc:creator>
      <dc:date>2026-04-29T20:21:47Z</dc:date>
    </item>
    <item>
      <title>Re: Incremental load with multiple delete flags</title>
      <link>https://community.qlik.com/t5/App-Development/Incremental-load-with-multiple-delete-flags/m-p/2548113#M110135</link>
      <description>&lt;P&gt;Incorrect response. In the incremental load logic, I want customers that are active and orders that are active. So if&amp;nbsp;&lt;SPAN&gt;IS_ORDER_DELETED changes from 0 to 1, then i still need all the customer data to display and null for all order related fields which i am not able to achieve with this script&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Apr 2026 21:16:06 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Incremental-load-with-multiple-delete-flags/m-p/2548113#M110135</guid>
      <dc:creator>lost_rabbit</dc:creator>
      <dc:date>2026-04-29T21:16:06Z</dc:date>
    </item>
    <item>
      <title>Re: Incremental load with multiple delete flags</title>
      <link>https://community.qlik.com/t5/App-Development/Incremental-load-with-multiple-delete-flags/m-p/2548137#M110137</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/138721"&gt;@lost_rabbit&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Could you please share some sample (dummy) data with these columns along with the expected output in Excel format? That will help clarify the requirement and build logic.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Apr 2026 04:23:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Incremental-load-with-multiple-delete-flags/m-p/2548137#M110137</guid>
      <dc:creator>vighnesh_gawad</dc:creator>
      <dc:date>2026-04-30T04:23:05Z</dc:date>
    </item>
    <item>
      <title>Re: Incremental load with multiple delete flags</title>
      <link>https://community.qlik.com/t5/App-Development/Incremental-load-with-multiple-delete-flags/m-p/2548166#M110141</link>
      <description>&lt;P&gt;Let me know if this helps&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;Customers:
LOAD * INLINE [
ID, NAME, IS_CUSTOMER_DELETED, LAST_UPDATE_DATE
1, Alice, 0,  2026-01-01
2, Bob,   0,  2026-01-01
3, John,  0,  2026-01-01
4, Ron,   1,  2026-01-01
];

Orders:
LOAD * INLINE [
ID, RATE, IS_ORDER_DELETED, LAST_UPDATE_DATE
1,  250,   0,     2026-01-06
2,  300,   0,     2026-01-07
3,  150,   1,     2026-01-08
];

/* Full Load - Expected Result
ID | NAME  | RATE | LAST_UPDATE_DATE
1  | Alice | 250  | 2026-01-06
2  | Bob   | 300  | 2026-01-07
3  | John  | NULL | 2026-01-01
*/

//Customers (3 &amp;amp; 4) updated
Customers: 
LOAD * INLINE [
ID, NAME, IS_CUSTOMER_DELETED, LAST_UPDATE_DATE
1, Alice, 0,  2026-01-01
2, Bob,   0,  2026-01-01
3, John,  1,  2026-05-05
4, Ron,   0,  2026-05-05 
]
;
// Orders (2,3,4) updated
Orders:
LOAD * INLINE [
ID, RATE, IS_ORDER_DELETED, LAST_UPDATE_DATE
1,  250,   0,     2026-01-06
2,  300,   1,     2026-03-03
3,  150,   0,     2026-03-03
4,  500,   0,     2026-03-03
];

/*
Incremental Load - Expected Result
ID | NAME  | RATE | LAST_UPDATE_DATE
1  | Alice | 250  | 2026-01-06
2  | Bob   | NULL | 2026-03-03
4  | Ron   | 500  | 2026-05-05
*/&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Apr 2026 09:13:16 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Incremental-load-with-multiple-delete-flags/m-p/2548166#M110141</guid>
      <dc:creator>lost_rabbit</dc:creator>
      <dc:date>2026-04-30T09:13:16Z</dc:date>
    </item>
    <item>
      <title>Re: Incremental load with multiple delete flags</title>
      <link>https://community.qlik.com/t5/App-Development/Incremental-load-with-multiple-delete-flags/m-p/2548250#M110162</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/138721"&gt;@lost_rabbit&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp; Here you go, you can apply this logic. you will get correct result. You will have to do some changes in script when you are using actual SQL tables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;FullLoad:
// Customers
Load ID, NAME, IS_CUSTOMER_DELETED, CUST_LAST_UPDATE_DATE
Where IS_CUSTOMER_DELETED = 0;
LOAD * INLINE [
ID, NAME, IS_CUSTOMER_DELETED, CUST_LAST_UPDATE_DATE
1, Alice, 0, 2026-01-01
2, Bob,   0, 2026-01-01
3, John,  0, 2026-01-01
4, Ron,   1, 2026-01-01
];

// Orders
Left Join (FullLoad)
Load *
Where IS_ORDER_DELETED = 0;
LOAD * INLINE [
ID, RATE, IS_ORDER_DELETED, LAST_UPDATE_DATE
1, 250, 0, 2026-01-06
2, 300, 0, 2026-01-07
3, 150, 1, 2026-01-08
];



MaxCustDateTable:
LOAD Max(CUST_LAST_UPDATE_DATE) as Max_CUST_LAST_UPDATE_DATE
Resident FullLoad;

LET vCustMaxDate = Peek('Max_CUST_LAST_UPDATE_DATE', 0, 'MaxCustDateTable');

DROP Table MaxCustDateTable;

MaxDateTable:
LOAD 
    Max(LAST_UPDATE_DATE) as Max_LAST_UPDATE_DATE
Resident FullLoad;

LET vMaxDate = Peek('Max_LAST_UPDATE_DATE', 0, 'MaxDateTable');

Drop Table MaxDateTable;

Customers: 
LOAD * INLINE [
ID, NAME, IS_CUSTOMER_DELETED, LAST_UPDATE_DATE
1, Alice, 0, 2026-01-01
2, Bob,   0, 2026-01-01
3, John,  1, 2026-05-05
4, Ron,   0, 2026-05-05
];




// Active (Insert/Update)
NewOrUpdatedCustomers:
NoConcatenate
LOAD * 
Resident Customers
Where LAST_UPDATE_DATE &amp;gt; '$(vCustMaxDate)'
AND IS_CUSTOMER_DELETED = 0;


//  Deleted
DeletedCustomers:
NoConcatenate
LOAD *
Resident Customers
Where LAST_UPDATE_DATE &amp;gt; '$(vCustMaxDate)'
AND IS_CUSTOMER_DELETED = 1;

drop table Customers;


// Collect IDs to replace/remove
UpdatedIDs:
LOAD ID as NewIDs  Resident NewOrUpdatedCustomers;

Concatenate (UpdatedIDs)
LOAD ID as NewIDs  Resident DeletedCustomers;


// Keep only unaffected old records
FilteredFullLoad:
NoConcatenate
LOAD *
Resident FullLoad
Where NOT Exists(NewIDs, ID);
drop table FullLoad;



Concatenate (FilteredFullLoad)
LOAD 
    ID,
    NAME,
    0 as IS_CUSTOMER_DELETED,
    LAST_UPDATE_DATE as CUST_LAST_UPDATE_DATE
Resident NewOrUpdatedCustomers;



DROP Tables 
    UpdatedIDs,
    NewOrUpdatedCustomers,
    DeletedCustomers;
    
    
// Orders (2,3,4) updated
Orders:
Mapping
Load ID, if(IS_ORDER_DELETED = 0, RATE) as NewRate
Where LAST_UPDATE_DATE &amp;gt; '$(vMaxDate)';
LOAD * INLINE [
ID, RATE, IS_ORDER_DELETED, LAST_UPDATE_DATE
1,  250,   0,     2026-01-06
2,  300,   1,     2026-03-03
3,  150,   0,     2026-03-03
4,  500,   0,     2026-03-03
];


FilteredFullLoadFinal:
NoConcatenate
LOAD ID, NAME, IS_CUSTOMER_DELETED, CUST_LAST_UPDATE_DATE,
   ApplyMap('Orders', ID, RATE) as RATE,
   IS_ORDER_DELETED,
   LAST_UPDATE_DATE
Resident FilteredFullLoad;
Drop table FilteredFullLoad;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 May 2026 15:41:29 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Incremental-load-with-multiple-delete-flags/m-p/2548250#M110162</guid>
      <dc:creator>vighnesh_gawad</dc:creator>
      <dc:date>2026-05-01T15:41:29Z</dc:date>
    </item>
  </channel>
</rss>

