Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
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
sunny_talwar

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

Not applicable
Author

Hi Sunny,

Could you please explain how the above function works?

Thanks,

Ankit

sunny_talwar

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))

Not applicable
Author

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)?

sunny_talwar

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