Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Create QVD with the oldest Record

Example data:

   

AmountTransaction Date CUSTOMER_ACCOUNT_ID
1478.7411/30/16 6:001
45611/30/16 8:001
15412/1/16 0:002
1897.4512/3/16 0:001
453812/3/16 0:003

I want the ONLY the older record from each ID saved in the QVD.

Initially I will have a QVD with all historic, then I want run this everyday and have it add only the customer ID's that dont exist.

PLEASE HELP.

LET vStartDate = MakeDate(2016,12,01);  

LET vEndDate = MakeDate(2016,12,03);  

FOR vDayNo = vStartDate to vEndDate;

LET vDate = Date(vDayNo, 'MM/DD/YYYY');

  Data:

  LOAD

    Amount as AMOUNT,

    "Transaction Date" as TRANSACTION_DATE,

    CUSTOMER_ACCOUNT_ID

  FROM [lib://AttachedFiles/Test.xlsx]

  (ooxml, embedded labels, table is Sheet1)

  WHERE Date("Transaction Date") = Date('$(vDate)') ;

  NoConcatenate

  Temp1:

  LOAD 

    TRANSACTION_DATE,

        CUSTOMER_ACCOUNT_ID,   

    sum( AMOUNT) AS  [AMOUNT]

  RESIDENT Data

    WHERE AMOUNT <> 0

    GROUP BY          

        TRANSACTION_DATE,CUSTOMER_ACCOUNT_ID;

NoConcatenate

    FirstLoadTemp:

    LOAD

  FirstSortedValue(AMOUNT, (TRANSACTION_DATE)) as Amount,

    Date(FLOOR(TRANSACTION_DATE)) as [Transaction Date],

  CUSTOMER_ACCOUNT_ID,

    CUSTOMER_ACCOUNT_ID2

  Resident Temp1

  Group by Date(FLOOR(TRANSACTION_DATE)), CUSTOMER_ACCOUNT_ID;   

   

         

  CONCATENATE(FirstLoad)

    LOAD  *

        FROM [lib://folder\Test.qvd](qvd)

     WHERE NOT EXISTS (CUSTOMER_ACCOUNT_ID2, CUSTOMER_ACCOUNT_ID);

          

   

    DROP FIELD CUSTOMER_ACCOUNT_ID2;

    STORE FirstLoad INTO [lib://folder\Test.qvd];

     

     DROP TABLE Data;

      Drop TABLE FirstLoad;

     DROP TABLE   Temp1;

     

     

      NEXT vDayNo

2 Replies
Anonymous
Not applicable
Author

swuehl  I have seen you reply to post similar to that. Can you please look into this.
THANK YOU!

Anonymous
Not applicable
Author

@stalwar1 Can you please please please help me with this. I have seen you help people with all sorts of things.
please. thanks!