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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
varunreddy
Creator III
Creator III

How to calculate last four weeks data?

Hi All,

I am trying to calculate last four weeks data.

I have a date field and latest date available is 5/27/2018 and minimum date is 1/12/2017.

I converted the date filed into Year and Week format.

So max week is 5/27/2018  (i.e.  Week22) Format - 2018-W22

Min Week - 1/12/2017 (i.e.  Week52) Format - 2017-W52

Now I want to show last four weeks data. this is the order of last four weeks.

1. 5/27/2018 - W22 (2018-W22)

2. 5/20 - 5/26 - W21

3. 5/13 - 5/19 - W20

4. 5/6 - 5/12 - W19

Can someone help me in getting data for 4 weeks?

I am able to get max week using the formula:

=Max(Year([Created date])&Week([Created date])) - Output - 201822

I am trying to find the way to get W19 (201819)

1 Solution

Accepted Solutions
varunreddy
Creator III
Creator III
Author

Hi Mayank,

Thanks for your response. I got it working. I calculated max date and then took weekend value as max value and then subtracted 28 days from it.

Cheers,

Varun

View solution in original post

4 Replies
mayankraoka
Specialist
Specialist

Just try

=Max(Year()&Week(),-4 )

Regards,

Mayank

varunreddy
Creator III
Creator III
Author

Hi Mayank,

It is still giving the maximum year and week.

Regards,

Varun

mayankraoka
Specialist
Specialist

Please share your application here...So that i can look into it.

Regards,

Mayank

varunreddy
Creator III
Creator III
Author

Hi Mayank,

Thanks for your response. I got it working. I calculated max date and then took weekend value as max value and then subtracted 28 days from it.

Cheers,

Varun