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

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
alec1982
Specialist II
Specialist II

Second sunday in each month

hi all,

I have a request to show sales amount on the second Sunday of each month. I have a date cloumn that has all dates in it.. is there a way to define the second Sunday in each month with a flag?

Best,

Alec

1 Solution

Accepted Solutions
alec1982
Specialist II
Specialist II
Author

thank you Sunny..

I tried something simpler and worked for me

if(Weekday([Date])='Sun' and day([Date])>7  and day([Date])<=14, 1,0) as SecSunFlag,

View solution in original post

4 Replies
sunny_talwar

May be something like this:

Table:

LOAD *,

  If(CumSundayFlag = 2 and SundayFlag = 1, 1, 0) as [2ndSundayFlag];

LOAD *,

  If(Month = Previous(Month), RangeSum(Peek('CumSundayFlag'), SundayFlag), SundayFlag) as CumSundayFlag;

LOAD *,

  Month(Date) as Month,

  If(WeekDay(Date) = 'Sun', 1, 0) as SundayFlag;

LOAD Date(MakeDate(2014, 1, 1) + RecNo()-1) as Date

AutoGenerate MakeDate(2016, 1, 1) - MakeDate(2014, 1, 1);

DROP Fields CumSundayFlag, SundayFlag;


Capture.PNG

alec1982
Specialist II
Specialist II
Author

thank you Sunny..

I tried something simpler and worked for me

if(Weekday([Date])='Sun' and day([Date])>7  and day([Date])<=14, 1,0) as SecSunFlag,

sunny_talwar

Great

It is indeed simpler.

Anonymous
Not applicable

Hey, It is giving me Script Line error for this.