Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Highlighted
ljackson
Contributor

Create a date range within a button

I need to select a date range (on a button) that does not include the current week.   I've searched the archives and found SO many date range related questions, but nothing that answers my query.

I want to select the last 4 weeks, previous to the current week.  This week is week 41, so I need the button to select weeks 37 to 40.

I've set the button actions as below, and it very happily selects from week 37 onwards, but I can't work out how to exclude the current week [max(WeekNo()].

Can anyone help?

Thank you.

Date Range.jpg

1 Solution

Accepted Solutions
ljackson
Contributor

Re: Create a date range within a button

I worked it out - thank you David for helping me find the last piece in the puzzle

I set up a variable, then selected the variable for the Field.   This then selected weeks 37 to 40.   I think this is the long winded way of doing it, but I get the result I need so I'm happy! 

Thanks again

Set Variable.jpg

Select Variable.jpg

7 Replies
dfoster9
Valued Contributor

Re: Create a date range within a button

try

=('>=' & Week(today()-35) & ' and ' & '< ' & Week(today()-7)

ljackson
Contributor

Re: Create a date range within a button

Thank you David.

I tweaked your expression to this:

=('>=' & Week(today()-28) & ' and ' & '<' & Week(today()))

In the selection box it now shows this:

Selection Box.jpg

but ........it's selecting all weeks less than 41, so has selected weeks 1 to 40.   It seems the second part of the expression is over-riding the first part.

ljackson
Contributor

Re: Create a date range within a button

I switched it around to this:

=('<' & Week(today()) & ' and ' & '>=' & Week(today()-28))

But now it's ignoring the first part of the expression, and includes weeks 37 to 52.

MVP
MVP

Re: Create a date range within a button

Could you share your sample app that shows the issue?

ljackson
Contributor

Re: Create a date range within a button

I worked it out - thank you David for helping me find the last piece in the puzzle

I set up a variable, then selected the variable for the Field.   This then selected weeks 37 to 40.   I think this is the long winded way of doing it, but I get the result I need so I'm happy! 

Thanks again

Set Variable.jpg

Select Variable.jpg

ljackson
Contributor

Re: Create a date range within a button

Here's the simple way:

Button.jpg

dfoster9
Valued Contributor

Re: Create a date range within a button

You are welcome. Could I be cheeky and get you mark my response as the correct/helpful answer. I know! I am a total points junkie 🙂