Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
i want to find YTD,MTD,WTD,QTD using Fiscal Year,Fiscal Month,Fiscal Week,Fiscal Quarter
Please give Solution for Following Data.
I need to count(ID) for fiscal year,Fiscal Month,Fiscal Week,Fiscal Quarter
Below is the sample date and id .Pls help asap
<
ID | DATE |
E1 | 12/06/2017 04:45 PM |
E2 | 12/07/2017 01:15 PM |
E3 | 29/07/2017 09:15 AM |
E4 | 29/07/2017 02:25 PM |
E5 | 21/07/2017 06:50 AM |
E6 | 13/07/2017 07:40 PM |
E7 | 01/12/2017 06:30 AM |
E8 | 02/12/2017 08:00 AM |
E9 | 01/12/2017 07:40 AM |
E10 | 01/12/2017 01:00 PM |
E11 | 03/12/2017 01:10 PM |
E12 | 03/12/2017 04:10 PM |
E13 | 04/12/2017 04:15 PM |
E14 | 01/12/2017 03:05 PM |
E15 | 01/12/2017 06:00 AM |
E16 | 03/12/2017 03:40 PM |
E17 | 04/12/2017 05:00 PM |
E18 | 05/12/2017 01:50 PM |
E19 | 03/01/2018 05:50 AM |
E20 | 03/01/2018 07:00 AM |
E21 | 03/01/2018 02:25 AM |
E22 | 03/01/2018 02:40 AM |
E23 | 01/02/2018 10:35 AM |
E24 | 02/02/2018 10:35 AM |
E25 | 03/02/2018 10:35 AM |
E26 | 04/02/2018 10:35 AM |
E27 | 05/02/2018 10:35 AM |
E28 | 06/02/2018 10:35 AM |
1st :
In this table; create a date field :
YourTable;
Load * ,
date(Date#(Subfield(DATE,' ',1),'DD/MM/YYYY')) as DateField
from source;
Then create a master Calendar as follow:
QuartersMap:
MAPPING LOAD
rowno() as Month,
'Q' & Ceil (rowno()/3) as Quarter
AUTOGENERATE (12);
Temp:
Load
min(DateField) as minDate,
max(DateField) as maxDate
Resident YourTable;
Let varMinDate = Num(Peek('minDate', 0, 'Temp'));
Let varMaxDate = Num(Peek('maxDate', 0, 'Temp'));
DROP Table Temp;
TempCalendar:
LOAD
$(varMinDate) + Iterno()-1 As Num,
Date($(varMinDate) + IterNo() - 1) as TempDate
AutoGenerate 1 While $(varMinDate) + IterNo() -1 <= $(varMaxDate);
MasterCalendar:
Load
TempDate AS DateField,
week(TempDate) As Week,
Year(TempDate) As Year,
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
Resident TempCalendar
Order By TempDate ASC;
Drop Table TempCalendar;
Then please refer to this link to create ur YTD MTD WTD QTD expressions (I tried to explain how to do it step by step)
Please find attached table and kindly provide Fiscal year's YTD, MTD,WTD,QTD logic for the same given data in query