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

Data is available.. Wee need to see demand for current week+ next two weeks

Current week is based on snapshot taken on monday 

And next two weeks should be update everyday


I already tried the logic with min week as curent week week and max week as week2 ... But im confused if its correct or not

Confused about "current week+newt two weeks".... Not sure why they simply call it three weeks ?

qvqfqlik
Creator
Creator
Author

How to write date ranges ?i was not ssking for metric calculation


varshavig12
Specialist
Specialist

If you want to filter your data for 3 weeks (current week + next 2 weeks )

Load *

from .....

where Your_date_field >=weekStart(today()) and Your_date_field <= weekEnd(Weekname(today(),2)) ;

Are you looking for something like this ?

qvqfqlik
Creator
Creator
Author

I tried this before... But I'm confused if my understanding of "current week + next 2 weeks" is same as the logic in thosevdate ranges.... Why dont they simply call this as 3 week demand?

varshavig12
Specialist
Specialist

Irrespective of what they say, the point is what they/you want to see as their/your output.

Only after once it is clear, we can try to help you in building the logic.

qvqfqlik
Creator
Creator
Author

could you please help me with this

Help with calculation-dates