[ Measures] = {Blank()}
[DAX DateDim] =
VAR BaseCalendar = CALENDAR ( date ( 2010, 1, 1) , today() ) RETURN // Create a date table with 1 line per day for the range 1/1/1990 to 31/12/2060
GENERATE ( BaseCalendar,
VAR TodayDayCycle = (today() - date( 1989, 12, 17) * 1)-(14*((ROUNDUP(ABS((today() - date( 1989, 12, 17) * 1)/14),0))-1))
VAR Cycles = ([Date] - 36724) / 14
VAR PayCycle = (ROUNDDOWN(Cycles,0)+1)-(ROUNDDOWN(Cycles/26,0))*26
VAR DaysInCycle = ([Date] - date( 1989, 12, 17) * 1)-(14*((ROUNDUP(ABS(([Date] - date( 1989, 12, 17) * 1)/14),0))-1))
VAR GRCFiscalYear =ROUNDDOWN(Cycles/26,0)+2000
Return ROW ( "DayNo", day([Date]), // number of current date
"Day ddd", Format([Date], "ddd"), //day name, Mon, Tue, Wed, etc
"DayInCycle", DaysInCycle*1, // number of days in paycycle
"WeekNo", WEEKNUM([Date]), // Gregorian week number
"WeekDay", if (or (Format([Date], "ddd") = "Sat", Format([Date], "ddd") = "Sun"), 0, 1) ,
"WeekDayNum", WEEKDAY([Date], 2 ), //
"WeekGRCNo", Weeknum([Date]-1635,2), // week number
"Week", [Date] + 7 - Weekday([Date], 2) ,
"CycleNo", PayCycle,
"CycleDate", [Date] + 14 - DaysInCycle , // Working!!
"Cycle Current?", if (today() + 14 - TodayDayCycle = [Date] + 14 - DaysInCycle, "Current","Other"),
"MonthNum", MONTH ( [Date] ), // Number of the gregorian month
"MonthName", FORMAT ( [Date], "mmmm" ), // Long name of current Month
"MonthEnd", EOMONTH( [Date], 0),
"Year", GRCFiscalYear,
"YearFiscal", if (MONTH ( [Date] )>6, YEAR ([Date]), YEAR ([Date])-1 ),
"YearLastDate", [Date] + (( 26- PayCycle +1 ) * 14 - DaysInCycle) , // add rmaining number of paycycles * nyumber of days per paycycle
"YearFirstDate", [Date] - ( PayCycle *14) - DaysInCycle + 15 )) // First calendar date of the Fiscal Year
Comments
Post a Comment