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: 
bonollojacopo4
Contributor
Contributor

Friday flag

Hi, i created a calendar 

 

MasterCalendar_tmp:

Load

TempDate AS Data_DP,

week(TempDate) As Week,

Year(TempDate) As Year,

num(Month(TempDate)) As Month,

Day(TempDate) As Day,

YeartoDate(TempDate)*-1 as CurYTDFlag,

YeartoDate(TempDate,-1)*-1 as LastYTDFlag,

inyear(TempDate, Monthstart($(varMaxDate)),-1) as RC12,

date(monthstart(TempDate), 'MMM-YYYY') as MonthYear,

ApplyMap('QuartersMap', month(TempDate), Null()) as Quarter,

Week(weekstart(TempDate)) & '-' & WeekYear(TempDate) as WeekYear,

WeekDay(TempDate) as WeekDay

 

 

I need to select all friday, then put them in increasing order, and then put a flag for identify the friday that is from a different month to the previous one. Someone can help? Thanks

Labels (1)
1 Reply
justISO
Specialist
Specialist

Hi, you can try something like this:

//loading only fridays and ordering by Data_DP
calendar_temp:
NoConcatenate
LOAD 
*,
num(WeekDay(Data_DP)) as weekday_num
RESIDENT MasterCalendar_tmp
WHERE num(WeekDay(Data_DP))=4
ORDER BY Data_DP;

//adding flag separately as previous() functuion not working in above part
calendar:
NoConcatenate
LOAD 
*,
if(Month<>previous(Month), 'flag', 'no') as flag   
RESIDENT calendar_temp;

DROP TABLES MasterCalendar_tmp, calendar_temp;