Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
MikeJones
Creator
Creator

Sum Sales for last 6 weeks

Hi, I am wishing to get the sum of sales for the last 6 complete weeks.  Given that today's date is 24th Aug 2023, I wish to get from 10th July to  20th August.

Next week I wish the calc to go from 17th July to 27th Aug.

I am using the following 

Sum({<[Date]={"$(= '>=' & WeekStart(Date(Today() - 43)) & '<=' & WeekStart(Date(Today()-7)))"}>}Sales).

However, when I look at daily data it sums from 10th July to Monday 14th Aug.

Labels (4)
1 Solution

Accepted Solutions
MikeJones
Creator
Creator
Author

Hi Digvijay, thanks for introducing me to the WeekEnd function.

I have used it to get 

Sum({<[Date]={"$(= '>=' & WeekStart(Date(Today() - 43)) & '<=' & WeekEnd(Date(Today()-7)))"}>}Sales) 

and my table shows the last 6 weeks results  and when I test it works.

Thanks again.

View solution in original post

3 Replies
Digvijay_Singh

I think you should use 2nd parameter of Weekstart to get the desired results.

I have not tested it but use something like below - 

Sum({<[Date]={"$(= '>=' & WeekStart(Date(Today(), - 7)) & '<=' & WeekEnd(Date(Today(),-1)))"}>}Sales)

Check after testing if -7 or -6 is the correct week you need to go backward to

MikeJones
Creator
Creator
Author

Hi Digvijay, thanks for introducing me to the WeekEnd function.

I have used it to get 

Sum({<[Date]={"$(= '>=' & WeekStart(Date(Today() - 43)) & '<=' & WeekEnd(Date(Today()-7)))"}>}Sales) 

and my table shows the last 6 weeks results  and when I test it works.

Thanks again.

Digvijay_Singh

But I still feel you should use 2nd parameter in Weekstart/end instead of subtracting days.