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: 
Not applicable

Calendar flag for dates during a certain period every year

Hi everyone,

Let's say I have an online marketplace that has a special sales period every November - February. I want to flag all sales dates that take place during that time period every season. So November 2013 - February 2014, November 2014 - February 2015, November 2015 - February 2016, etc. Is there a way to create such a flag in the calendar like is so often done with current YTD and last YTD?

1 Solution

Accepted Solutions
sunny_talwar

Try this:

Table:

LOAD *,

  If(Match(Num(Month), 11, 12, 1, 2), 1, 0) as Flag,

  If(Match(Num(Month), 11, 12), 'Holiday ' & Year & '-' & (Year + 1),

  If(Match(Num(Month), 1, 2), 'Holiday ' & (Year - 1) & '-' & Year)) as HolidayFlag;

LOAD *,

  Month(Date) as Month,

  Year(Date) as Year,

  MonthName(Date) as MonthYear;

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

AutoGenerate (MakeDate(2015, 12, 31) - MakeDate(2010, 1, 1));

View solution in original post

4 Replies
sunny_talwar

What if you do something like this:

Table:

LOAD *,

  If(Match(Num(Month), 11, 12, 1, 2), 1, 0) as Flag;

LOAD *,

  Month(Date) as Month,

  Year(Date) as Year,

  MonthName(Date) as MonthYear;

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

AutoGenerate (MakeDate(2015, 12, 31) - MakeDate(2010, 1, 1));

Not applicable
Author

Thanks for the response, this is a good start. Is it possible to tag the dates according to the year they were sold, similar to a fiscal year? So for example, a sale on December 1, 2013 would be flagged as part of the "Holiday 2013-2014" period (because it's between November 2013 and February 2014), January 16, 2015 would be flagged as part of the "Holiday 2014-2015" period (because it's between November 2014 and February 2015), etc.

Sorry, I should've made this part clearer in my initial question.

sunny_talwar

Try this:

Table:

LOAD *,

  If(Match(Num(Month), 11, 12, 1, 2), 1, 0) as Flag,

  If(Match(Num(Month), 11, 12), 'Holiday ' & Year & '-' & (Year + 1),

  If(Match(Num(Month), 1, 2), 'Holiday ' & (Year - 1) & '-' & Year)) as HolidayFlag;

LOAD *,

  Month(Date) as Month,

  Year(Date) as Year,

  MonthName(Date) as MonthYear;

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

AutoGenerate (MakeDate(2015, 12, 31) - MakeDate(2010, 1, 1));

Not applicable
Author

This works, thanks!