Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Zurich on Sept 24th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
MarioCenteno
Creator III
Creator III

Load current month data with do while

I am using a do while to try to bring data for the current month, but only upload data until the previous month I need your help please.


/* >> LOADA DATA PER PERIODS ========================================= */

LET vPeriodo = (YEAR(TODAY())) & '0'; // CURRENT A YEAR

LET vMesActual = NUM(MONTH(TODAY())); // CURRENT ACTUAL

LET vMesProximo = NUM(MONTH(TODAY())+1); // NEXT MONTH

LET vI = 7; // INITIAL MONTH

DO WHILE vI <= vMesActual

LET vCiclo = vPeriodo & vI; // BUILD YEAR-MONTH

TRACE $(vCiclo);

LET vCiclo = vCiclo & '01'; // BUILD YEAR-MONTH-FIRSTDAY

LOAD

SELECT * FROM TABLE

WHERE DATE =  TRUNC(LAST_DAY('$(vCiclo)'))

LET vI = vI + 1;

LOOP;

13 Replies
petter
Partner - Champion III
Partner - Champion III

Sorry - I was a bit quick... the code should be like this instead:

vDate = Date(Date#('20180701','YYYYMMDD'),'YYYYMMDD');  

DO WHILE vDate <= Today(1) 

  /* TRACE */ SELECT * FROM TABLE WHERE DATE = TO_DATE('$(vDate)','YYYYMMDD');  

  LET vDate = Date( vDate+1 ,'YYYYMMDD'); 

LOOP

MarioCenteno
Creator III
Creator III
Author

Thanks for responding, I have corrected and it works but it only loads 52 clients and they are approximately 10K.


Because it will be that it does not charge every day, there will be a way to load it with daily and keep it in the table


I need your help please.


c.png

ciclo 2.png


petter
Partner - Champion III
Partner - Champion III

I think I have answered your question. Wouldn't it be better to pose a new question about your additional challenge. You could simply use the title "How to do incremental load" and refer to this thread.

I would appreciate if you mark this thread as answered - then you could continue getting help by me or others on the new thing on a different thread. OK?

MarioCenteno
Creator III
Creator III
Author

Okay, Petter, I appreciate all your time I'll ask another question about this.