Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Announcements
QlikWorld, June 24-25, 2020. Free virtual event for DI and DA gurus. Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Not applicable

Dates

Can someone please explain how this function works

(If(Date(Date1)<WeekEnd(today()-14,1,0) and Date(Date1)>=WeekEnd(today()-21,1,0), Date1))

How is weekend and today related here

5 Replies
Highlighted

Re: Dates

Not sure I understand your question. How is WeekEnd and Today() related, what do you mean?

Highlighted
Not applicable

Re: Dates

Hi Sunny,

Could you please explain how the above function works?

Thanks,

Ankit

Highlighted

Re: Dates

Where are you using this? As a calculated dimension?

I think it is trying to list date for last week. When I checked WeekEnd(today()-14,1,0) it showed me last weekend date 9/25/2016

Capture.PNG


And this -> WeekEnd(today()-21,1,0) give me last week start date 9/18/2016

Capture.PNG

So, from the looks it seems that the expression is grabbing Date1 between 9/18/2016 to 9/25/2016 (the last completed week). May be an easier way to write this would be this,

If(Date1 >= WeekStart(Today(), -1, 0) - 1 and Date1 < WeekEnd(Today(), -1, 0), Date1))

Highlighted
Not applicable

Re: Dates

Thanks,Sunny that was very useful,i am not sure how why does ,1,0  signifies in WeekEnd(today()-14,1,0)?

can't we just use WeekEnd(today()-14)?

Highlighted

Re: Dates

Take a look at the weekend function here

https://help.qlik.com/en-US/qlikview/12.0/Subsystems/Client/Content/Scripting/DateAndTimeFunctions/w...

1 will show one week forward, whereas -1 will take you one week back from your Today()-14 date. So

WeekEnd(Today()-14) is NOT equal to WeekEnd(Today()-14, 1, 0).

WeekEnd(Today()-14) = WeekEnd(Today()-14, 0, 0)

I hope this will clarify any left over doubts that you might have.

Best,

Sunny