Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Update Modified Date Field while Keeping Create Date Field

Hello,

I would like to be able to update fields in a stored QVD file while retaining the original Created_Date field. The 'Key' would be a combination of both Product_ID and Company_ID, since multiple companies can share the same product type. Please see the below examples of what I'd like to do:

QVD Table:

PRODUCT_IDCOMPANY_IDCREATED_DATEMODIFIED_DATE
011001/1/20164/1/2016
021002/1/20164/1/2016
032004/1/20164/1/2016

New Table:

PRODUCT_IDCOMPANY_IDMODIFIED_DATE
011006/1/2016
032006/1/2016
033006/1/2016

Desired Result:

PRODUCT_IDCOMPANY_IDCREATED_DATEMODIFIED_DATE
011001/1/20166/1/2016
021002/1/20164/1/2016
032004/1/20166/1/2016
033006/1/20166/1/2016

I have tried to start this process with an incremental load (inserting and updating fields), but am not able to retain the Created_Date field. Do you have any suggestions?

Thanks in Advance!

1 Solution

Accepted Solutions
maxgro
MVP
MVP

Tmp:

LOAD PRODUCT_ID,

     COMPANY_ID,

     MODIFIED_DATE as M2,

     PRODUCT_ID & '|' & COMPANY_ID as key

FROM

  [https://community.qlik.com/thread/235704] (html, codepage is 1252, embedded labels, table is @2);

JOIN (Tmp)

LOAD PRODUCT_ID,

     COMPANY_ID,

     MODIFIED_DATE as M1,

     CREATED_DATE as C1

FROM

  [https://community.qlik.com/thread/235704] (html, codepage is 1252, embedded labels, table is @1);

Final:

load PRODUCT_ID,

     COMPANY_ID,

     IF(len(trim(M2)), M2, M1) as MODIFIED_DATE,

     IF(len(trim(C1)), C1, M2) as CREATED_DATE

Resident Tmp;

DROP Table Tmp;

1.png

View solution in original post

4 Replies
sfatoux72
Partner - Specialist
Partner - Specialist

‌Try somme thing Luke this:

Data:

Load PRODUCT_ID, COMPANY_ID, CREATED_DATE, MODIFIED_DATE as MODIFIED_DATE_OLD

from QVD_Table ;

left join (Data)

Load PRODUCT_ID, COMPANY_ID, MODIFIED_DATE as MODIFIED_DATE_NEW

from NEW_Table ;

left join (Data)

Load PRODUCT_ID, COMPANY_ID,  If(isnull(MODIFIED_DATE_NEW), MODIFIED_DATE_OLD, MODIFIED_DATE_NEW) as MODIFIED_DATE

Resident Data ;

drop field MODIFIED_DATE_OLD;

drop field MODIFIED_DATE_NEW;

maxgro
MVP
MVP

Tmp:

LOAD PRODUCT_ID,

     COMPANY_ID,

     MODIFIED_DATE as M2,

     PRODUCT_ID & '|' & COMPANY_ID as key

FROM

  [https://community.qlik.com/thread/235704] (html, codepage is 1252, embedded labels, table is @2);

JOIN (Tmp)

LOAD PRODUCT_ID,

     COMPANY_ID,

     MODIFIED_DATE as M1,

     CREATED_DATE as C1

FROM

  [https://community.qlik.com/thread/235704] (html, codepage is 1252, embedded labels, table is @1);

Final:

load PRODUCT_ID,

     COMPANY_ID,

     IF(len(trim(M2)), M2, M1) as MODIFIED_DATE,

     IF(len(trim(C1)), C1, M2) as CREATED_DATE

Resident Tmp;

DROP Table Tmp;

1.png

Not applicable
Author

Unfortunately this didn't work - Created Date is not populated for new products. It also doesn't take into account Company_ID and Product_ID

Not applicable
Author

This works great, thank you!