Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Manish
Creator
Creator

Customized date range for months

Hi,

We have a requirement where we want to have a customized date range for the months.

For example :

Jan 2023 {29/12/2023 - 26/01/2023 } should have dates ranging from Last Thursday of previous month (Dec 2022) to Last Thursday of Current month (Jan 2023)  - 

Nov 2023 - {26/10/2023 - 30/11/2023} and so on and so forth.

Thanks

Labels (2)
2 Solutions

Accepted Solutions
Gabbar
Specialist
Specialist

As you mentioned this Jan 2023 {29/12/2023 - 26/01/2023 } 
So i presume a month starts from last friday of last month and end at its last thursday;

Try This:-
Load RN,Day,Date(RN) as Date, Month(RN) as Original,Month(D_) as required;
Load *, If(D = '0',RN,7+RN-D) as D_,weekday(If(D = '0',RN,7+RN-D)) as w_da;
Load *, weekday(RN) as Day, IF(Num(Weekday(RN))-3>=0,Num(Weekday(RN))-3,Num(Weekday(RN))+4) as D;
////////////////// D Coulmn gives me next nearest thursday date difference, D_ becomes next thursday and 
month(D_) becomes your required month//////////////////////////// 
Load RecNo() as RN
AutoGenerate 500;

Adjust accordingly, Required Column is your required month, original column is just month name,
and RN is datefield.

View solution in original post

hic
Former Employee
Former Employee

Take a look at 

https://community.qlik.com/t5/Member-Articles/Calendars/ta-p/1496392

What you want is very similar to a Broadcast calendar.

View solution in original post

4 Replies
HKN1
Contributor III
Contributor III

Manish
Creator
Creator
Author

Thanks for replying but I want to customize the data range for every month?

For example :  Nov 2023 Month year should have date range from last Thursday of Previous Month (i.e. 26/10/2023) till Last Thursday of Current Month (i.e. 30/11/2023) and so on and so forth and not from 01/11/2023 to 30/11/2023).

Any idea how can I achieve this?

Gabbar
Specialist
Specialist

As you mentioned this Jan 2023 {29/12/2023 - 26/01/2023 } 
So i presume a month starts from last friday of last month and end at its last thursday;

Try This:-
Load RN,Day,Date(RN) as Date, Month(RN) as Original,Month(D_) as required;
Load *, If(D = '0',RN,7+RN-D) as D_,weekday(If(D = '0',RN,7+RN-D)) as w_da;
Load *, weekday(RN) as Day, IF(Num(Weekday(RN))-3>=0,Num(Weekday(RN))-3,Num(Weekday(RN))+4) as D;
////////////////// D Coulmn gives me next nearest thursday date difference, D_ becomes next thursday and 
month(D_) becomes your required month//////////////////////////// 
Load RecNo() as RN
AutoGenerate 500;

Adjust accordingly, Required Column is your required month, original column is just month name,
and RN is datefield.

hic
Former Employee
Former Employee

Take a look at 

https://community.qlik.com/t5/Member-Articles/Calendars/ta-p/1496392

What you want is very similar to a Broadcast calendar.