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

Last 7weeks and 7months calulation

Hi,

I have calendar with all fields, whereas i need to set trigger for button to select last 7weeks and 7months.

I tried with select in field trigger, but it is not working. Can any one suggest what will be the right expression for this?

I tried with this,

='>='&(WeekStart(Max(Date), -6))&'<='&(WeekEnd(Max(Date),+1)) - For Week

Same as MONTH.

Thanks,

Raju

1 Solution

Accepted Solutions
settu_periasamy
Master III
Master III

Hi,

I just changed the Some of your Date Fields based on your QVD, and now it seems to be working.

Check the Attachment.

View solution in original post

7 Replies
tresesco
MVP
MVP

Could you post a sample qvw?

raju_salmon
Creator II
Creator II
Author

Hi,

Please find the attached sample app.

settu_periasamy
Master III
Master III

Hi,

I think in your table the Date is field is in UPPER case. It should be like

='>='&(WeekStart(Max(DATE), -6))&'<='&(WeekEnd(Max(DATE),+1))

It will give the return value >=1/12/2026<=3/8/2026  (if there is no Selection)

And, There is no CAL_WEEK for FEB - 2026 and MAR-2026. It show till Jan 2026.

Can you check your CAL_WEEK Field?

tresesco
MVP
MVP

A general word of suggestion: - always try to create date fields using date functions, so that the created field values have numeric representation at the backend and you can apply other date functions on it. If you create the field as a text field (as it is now - your CAL_WEEK and CAL_MONTH fields), the values can't be compared/calculated directly using date functions.

Week - '11 Apr 2009' - what does it mean?

perumal_41
Partner - Specialist II
Partner - Specialist II

Hi Raju

PFB below expression

=Sum({<Date={'>=$(=WeekEnd(Max(Date) -49) <=$(=WeekEnd(Max(Date))+1)'}>}sales) - For Week

=Sum({<Date={'>=$(=addmonth(Mothend(Max(Date) ),-7)) <=$(=MonthEnd(Max(Date)))'}>}sales)  For month

raju_salmon
Creator II
Creator II
Author

Thanks for good suggestion Tresesco, we have created calendar in SQL server, that might be the issue here. I will take care of it.

settu_periasamy
Master III
Master III

Hi,

I just changed the Some of your Date Fields based on your QVD, and now it seems to be working.

Check the Attachment.