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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
qvqfqlik
Creator
Creator

min max dates

i need to find min and max dates for current week

LET vCW = peek('CYW',0,'table1');

LET vMinCurrentWk = (WeekStart($(vCW))));

LET vMaxCurrentWk = WeekDay(WeekEnd($(vCW)));

please help

vCW is returning  current yearweek. No issue with this. But need to find min and max of current week.

20 Replies
maxgro
MVP
MVP

this will work only for  201628

Yes, I wrote in my post

Replace 201628 with your field or variable

I wan the Min date to start from Sunday, and Max date to be Saturday.

swuehl already answered (subtract 1 or redefine the week start)

qvqfqlik
Creator
Creator
Author

Thankyou....and Also, within  the script, how to calculate a metric for  (current week + next 3 weeks) data -> next 3 weeks should be updated everyday. Please help

qvqfqlik
Creator
Creator
Author

Thankyou. Calendar is not same as system calendar. Also, within  the script, how to calculate a metric for  (current week + next 3 weeks) data -> next 3 weeks should be updated everyday. Please help

vinieme12
Champion III
Champion III

can you post a sample?

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
qvqfqlik
Creator
Creator
Author

I am done with the current week part. I need to get next part.

I need to calculate a Dmnd metric for  (current week+ next two weeks)

Current week demnd is snapshot of current week

next two weeks demnd have to be updated everyday

for current week demnd I tried to restrict the "where" condition as below

CWkdata:

NoConcatenate

  LOAD

  mat_key,

  TODAY() as cal_key,

  Sum( dd)  as Dmnd  // this is the metric

  FROM

  abcd.QVD (qvd)

  Where

wkbeg >= $(vMinCurrentWk)

wkend <= $(vMaxCurrentWk)

Group By

mat_key, TODAY();


I have created two tables for and next week and the next to next week as below


//Next Week

Caltable:

NoConcatenate
LOAD DISTINCT
YRWK
FROM calendr.QVD (qvd)
Where CALDT = Today() + 7
;

W1:

NoConcatenate
LOAD
YRWK as Yw1
Resident Caltable
Order By
YWK
;

LET vW1 = peek('Yw1',0,'W1');  // this is calculating next week , i.e  '201629'

DROP Table Caltable;

//2 Weeks

Caltable:

NoConcatenate
LOAD DISTINCT
YRWK
FROM calendr (qvd)
Where CALDT = Today() + 21;

W2:

  NoConcatenate

  LOAD

  YRWK as Yw2

  Resident Caltable

  Order By

  YRWK;

LET vW2 = peek('Yw2',0,'W2');  // this is calculating next week , i.e  '201631'

DROP Table Caltable;

how to calculate next 2 weeks demnd to have to be updated everyday?

Please help

qvqfqlik
Creator
Creator
Author

I need to calculate a Dmnd metric for  (current week+ next two weeks)

Current week demnd is snapshot of current week

next two weeks demnd have to be updated everyday

for current week demnd I tried to restrict the "where" condition as below

CWkdata:

NoConcatenate

  LOAD

  mat_key,

  TODAY() as cal_key,

  Sum( dd)  as Dmnd  // this is the metric

  FROM

  abcd.QVD (qvd)

  Where

wkbeg >= $(vMinCurrentWk)

wkend <= $(vMaxCurrentWk)

Group By

mat_key, TODAY();


I have created two tables for and next week and the next to next week as below


//Next Week

Caltable:

NoConcatenate
LOAD DISTINCT
YRWK
FROM calendr.QVD (qvd)
Where CALDT = Today() + 7
;

W1:

NoConcatenate
LOAD
YRWK as Yw1
Resident Caltable
Order By
YWK
;

LET vW1 = peek('Yw1',0,'W1');  // this is calculating next week , i.e  '201629'

DROP Table Caltable;

//2 Weeks

Caltable:

NoConcatenate
LOAD DISTINCT
YRWK
FROM calendr (qvd)
Where CALDT = Today() + 21;

W2:

  NoConcatenate

  LOAD

  YRWK as Yw2

  Resident Caltable

  Order By

  YRWK;

LET vW2 = peek('Yw2',0,'W2');  // this is calculating next week , i.e  '201631'

DROP Table Caltable;

how to calculate next 2 weeks demnd to have to be updated everyday?

Please help

qvqfqlik
Creator
Creator
Author

I need to calculate a Dmnd metric for  (current week+ next two weeks)

Current week demnd is snapshot of current week

next two weeks demnd have to be updated everyday

for current week demnd I tried to restrict the "where" condition as below

CWkdata:

NoConcatenate

  LOAD

  mat_key,

  TODAY() as cal_key,

  Sum( dd)  as Dmnd  // this is the metric

  FROM

  abcd.QVD (qvd)

  Where

wkbeg >= $(vMinCurrentWk)

wkend <= $(vMaxCurrentWk)

Group By

mat_key, TODAY();


I have created two tables for and next week and the next to next week as below


//Next Week

Caltable:

NoConcatenate
LOAD DISTINCT
YRWK
FROM calendr.QVD (qvd)
Where CALDT = Today() + 7
;

W1:

NoConcatenate
LOAD
YRWK as Yw1
Resident Caltable
Order By
YWK
;

LET vW1 = peek('Yw1',0,'W1');  // this is calculating next week , i.e  '201629'

DROP Table Caltable;

//2 Weeks

Caltable:

NoConcatenate
LOAD DISTINCT
YRWK
FROM calendr (qvd)
Where CALDT = Today() + 21;

W2:

  NoConcatenate

  LOAD

  YRWK as Yw2

  Resident Caltable

  Order By

  YRWK;

LET vW2 = peek('Yw2',0,'W2');  // this is calculating next week , i.e  '201631'

DROP Table Caltable;

how to calculate next 2 weeks demnd to have to be updated everyday?

Please help

qvqfqlik
Creator
Creator
Author

Could you please help me with this

qvqfqlik
Creator
Creator
Author

Could you please help me with this

qvqfqlik
Creator
Creator
Author

Please ignore typo... Its today()+14 for week2