Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
satishkurra
Valued Contributor II

This Week and Last Week

Hi

I'm currently using the below boolean functions to get This Week and Last Week.

-InWeekToDate(Date,Today(),0) as CurrentWeek,

-InWeekToDate(Date,Today(),-1) as PreviousWeek,

For Current Week, it is showing Date as 08/08 and 08/07

and

For Last week, it is showing Date as 07/31 and 08/01.

I want to show Current Week from 08/07  - 08/13

and in the similar way Last week as well.

Can Someone help me in achieving this.

Besides this for Date Range Calculation i would like to use flag

For example, From Aug 1 - Aug 31 (full month Estimation using Flags)

I do not want Max(Date) as i have Dates after Aug 31 2016 as well

I need from Aug 1 2016 and Aug 31 2016 logic using Flags

Thanks

Satish

1 Solution

Accepted Solutions

Re: This Week and Last Week

May be try this:

Table:

LOAD *,

  InWeekToDate(Date, WeekEnd(Today()), 0) as CurrentWeek,

  InWeekToDate(Date, WeekEnd(Today()), -1) as PreviousWeek;

LOAD Date(MonthStart(Today(), -1) + RecNo() - 1) as Date

AutoGenerate 44;

7 Replies
MVP
MVP

Re: This Week and Last Week

Try using function InWeek() instead of InWeekToDate().

Re: This Week and Last Week

May be try this:

Table:

LOAD *,

  InWeekToDate(Date, WeekEnd(Today()), 0) as CurrentWeek,

  InWeekToDate(Date, WeekEnd(Today()), -1) as PreviousWeek;

LOAD Date(MonthStart(Today(), -1) + RecNo() - 1) as Date

AutoGenerate 44;

satishkurra
Valued Contributor II

Re: This Week and Last Week

Both solutions worked...

Thanks

Also how can we get the logic using flags for Date Range.

For example, the data should be displayed from Aug 1 - Aug 31 (Using Flags)

Currently i'm using

InMonthToDate(Date, Today(), 0)

Can i replace the above to

InMonthToDate(Date, MonthEnd(today(), 0) ?

Re: This Week and Last Week

I feel that should work, what do you think Stefan?

satishkurra
Valued Contributor II

Re: This Week and Last Week

It worked . But i will wait for you guys to confirmSmiley Happy

Re: This Week and Last Week

Best way is to test it out

Capture.PNG

Using the script:

Table:

LOAD *,

  InWeekToDate(Date, WeekEnd(Today()), 0) as CurrentWeek,

  InWeekToDate(Date, WeekEnd(Today()), -1) as PreviousWeek,

  InMonthToDate(Date, MonthEnd(Today()), 0) as CurrentMonth;

LOAD Date(MonthStart(Today(), -1) + RecNo() - 1) as Date

AutoGenerate 365;

MVP
MVP

Re: This Week and Last Week

Satish Kurra wrote:

It worked . But i will wait for you guys to confirmSmiley Happy

?

You want me to confirm what you already proved working? Why that?

It seems you like the more complex functions over the slighty more simple ones, note that there are a lot more functions to create flags for dates in the script, best to have a good read through the relevant date and time functions HELP pages.

Community Browser