Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
migueldelval
Specialist
Specialist

Set analysis to use only some weeks

Hi all,

I´m using the next expression to only show the last 5 weeks, when I select  a date.

=Sum({<Date={">=$(=WeekStart(Max(Date)-28))<=$(=Max(Date))"}>}Sales)

But now, I only need to see weeks that are in the same month that selected date.

My Date field its like:

...

16/05/2016

23/05/2016

30/05/2016

...

Thank you in advance

1 Solution

Accepted Solutions
migueldelval
Specialist
Specialist
Author

Thank you stalwar1 and tresesco,

Finnaly the correct answer was:

=Sum({<Datefield={">=$(=MonthStart(Weekstart(datefield)))<=$(=Max(Datefield))"}>}[Sales)

With this expressión my chart only show weeks that are in month selected in date field.

In order words, if I select Datefield = 30/05/2016. My chart show only 5 weeks; and all of this weeks, Monday it´s in May.

Little bit strange but correct to my requirement.

View solution in original post

3 Replies
tresesco
MVP
MVP

May be like:

=Sum({<Date={">=$(=WeekStart(MonthStart(Max(Date))))<=$(=Date(Max(Date)))"}>}Sales)

sunny_talwar

Or may be this:

=Sum({<Date={">=$(=Date(WeekStart(Max(Date)-28), 'DD/MM/YYYY'))<=$(=Date(Max(Date), 'DD/MM/YYYY'))"}>}Sales)

migueldelval
Specialist
Specialist
Author

Thank you stalwar1 and tresesco,

Finnaly the correct answer was:

=Sum({<Datefield={">=$(=MonthStart(Weekstart(datefield)))<=$(=Max(Datefield))"}>}[Sales)

With this expressión my chart only show weeks that are in month selected in date field.

In order words, if I select Datefield = 30/05/2016. My chart show only 5 weeks; and all of this weeks, Monday it´s in May.

Little bit strange but correct to my requirement.