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

Announcements
Qlik Connect 2026! Turn data into bold moves, April 13 -15: Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
qvqfqlik
Creator
Creator

help with metric calculation

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

Current week dmnd is snapshot of current week

next two weeks dmnd have to be updated everyday

for current week dmnd 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

15 Replies
qvqfqlik
Creator
Creator
Author

Could someone please help me with this

varshavig12
Specialist
Specialist

if current week is today()

week1 = today()+7

Then , week2 = today()+14   Right ?

qvqfqlik
Creator
Creator
Author

Yes... I wrote the 3rd week earlier... Please consider as today()+14

varshavig12
Specialist
Specialist

You can use Weekname(today()) for current week

and weekname(today(),2) for the next two weeks

qvqfqlik
Creator
Creator
Author

Question- What is meant by current week+next 2 weeks data ?

Why cant we call this as 3 weeks instead ?

varshavig12
Specialist
Specialist

I simply meant,

for eg: If today's week is 23

weekname(today(),2) will return 25.

qvqfqlik
Creator
Creator
Author

No , I was asking a question in general, as I have to calculate that metric for current week+next 2 weeks

Where current week snapshot is taken on monday and next two weeks should update everyday

Please help



vinieme12
Champion III
Champion III

Is the data available for the next two weeks or should they be forecasted?

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
varshavig12
Specialist
Specialist

I'm not very sure,

But you can try this in your code

wkbeg >= $(vMinCurrentWk)        i.e  weekStart(today())

wkend <= $(vMaxCurrentWk)       i.e weekEnd(Weekname(today(),2))