Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
ericdelaqua
Creator
Creator

All transaction UP TO Flag

Hello,

I need some help with my master calendar. I am trying to add 3 flag. so that when the user selects this flags all transactions are selected except current,last,last2 months record respectively.

All dates UP_TO_lastMonth_Flag

All dates UP_TO_2Months_Ago_Flag

All dates UP_TO_3Months_Ago_Flag

My calendar code is below. Thanks

 

Let vToday = num(Today());

MasterCalendar: 

Load 

 Date(TempDate,'DD MMM YYYY'AS Date, 

 week(TempDate) As Week, 

 Year(TempDate) As Year, 

 Month(TempDate) As Month,

  Year(TempDate) &'-'Month(TempDate) as YearMonth,

  Year(AddMonths(TempDate,6)) as FinYr,

   Num(Month(AddMonths(TempDate,6)),'00'as FinPeriod,

 Day(TempDate) As Day, 

 'Q' & ceil(month(TempDate) / 3AS Quarter, 

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

 Year(TempDate) & '-' & Week(TempDate) as YearWeek,

 WeekDay(TempDate) as WeekDay,

 ///Flags

If(TempDate>$(vToday),1,0as FutureFlag,

If(TempDate=$(vToday),1,0as TodaysFlag,

InWeekToDate(TempDate, WeekEnd(Today()), 0)* -1 as CurrentWeekFlag,

InWeekToDate(TempDate, WeekEnd(Today()), -1)* -1 as PreviousWeekFlag,

IfInMonth (TempDate, $(vToday), +1),1as NextMonthFlag,

inyeartodate(TempDate,$(vToday),0) * -1 as CurYTDFlag,

inyeartodate(TempDate,$(vToday),-1) * -1 as LastYTDFlag,

inmonthtodate(TempDate,$(vToday),0) * -1 as CurMTDFlag,

inmonthtodate(TempDate,$(vToday),+1) * -1 as NextMTDFlag,

inmonthtodate(TempDate,$(vToday),-1) * -1 as LastMTDFlag,

IfInMonth (TempDate, $(vToday),0),1,0as This_Month_Flag

;

//=== Generate a temp table of dates === 

LOAD 

 date(mindate + IterNo()) AS TempDate

 ,maxdate // Used in InYearToDate() above, but not kept 

WHILE mindate + IterNo() <= maxdate;

//=== Get min/max dates from Field ===/

LOAD

 min(FieldValue('Date'recno()))-1 as mindate,

 max(FieldValue('Date'recno())) as maxdate

AUTOGENERATE FieldValueCount('Date');

 

Labels (1)
1 Solution

Accepted Solutions
MayilVahanan

HI @ericdelaqua 

Try like below

Assign 3 variables

Let vUP_TO_lastMonth_Flag = Floor(MonthEnd(Today(),-1));
Let vUP_TO_2Months_Ago_Flag = Floor(MonthEnd(Today(),-2));
Let vUP_TO_3Months_Ago_Flag = Floor(MonthEnd(Today(),-3));

Add below lines in master calendar

Load *,

if(TempDate <= $(vUP_TO_lastMonth_Flag), 1, 0) as UP_TO_lastMonth_Flag,
if(TempDate <= $(vUP_TO_2Months_Ago_Flag), 1, 0) as UP_TO_2Months_Ago_Flag,
if(TempDate <= $(vUP_TO_3Months_Ago_Flag), 1, 0) as UP_TO_3Months_Ago_Flag,

 

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.

View solution in original post

2 Replies
MayilVahanan

HI @ericdelaqua 

Try like below

Assign 3 variables

Let vUP_TO_lastMonth_Flag = Floor(MonthEnd(Today(),-1));
Let vUP_TO_2Months_Ago_Flag = Floor(MonthEnd(Today(),-2));
Let vUP_TO_3Months_Ago_Flag = Floor(MonthEnd(Today(),-3));

Add below lines in master calendar

Load *,

if(TempDate <= $(vUP_TO_lastMonth_Flag), 1, 0) as UP_TO_lastMonth_Flag,
if(TempDate <= $(vUP_TO_2Months_Ago_Flag), 1, 0) as UP_TO_2Months_Ago_Flag,
if(TempDate <= $(vUP_TO_3Months_Ago_Flag), 1, 0) as UP_TO_3Months_Ago_Flag,

 

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
ericdelaqua
Creator
Creator
Author

Thanks @MayilVahanan ,

This is the solution I was after.