Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi Team,
I am looking for following solution I wanted to display YTD/MTD/QTD/Rolling 3 months / Rolling 12 months in filter pane
In measures i wanted to calculate growth% & market share following are the sample data.
Sample_Int:
LOAD * INLINE [
Month, Sales
Jan-09, 55
Feb-09, 39
Mar-09, 33
Apr-09, 56
May-09, 55
Jun-09, 70
Jul-09, 57
Aug-09, 29
Sep-09, 34
Oct-09, 41
Nov-09, 12
Dec-09, 11
Jan-10, 24
Feb-10, 85
Mar-10, 99
Apr-10, 77
May-10, 85
Jun-10, 64
Jul-10, 61
Aug-10, 45
Sep-10, 62
Oct-10, 70
Nov-10, 59
Dec-10, 25
Jan-11, 86
Feb-11, 92
Mar-11, 67
Apr-11, 65
May-11, 39
Jun-11, 70
];
I tried with diff approaches but no luck . can any one have this logic please share your thoughts.
Measures :
S.no |
Measure |
1 |
%Growth Vs PY = (Current Value - Prior Value)/Prior Value*100 |
2 |
% Market Share = (Total sales of the company/ Total sales of the market)*100 |
Thanks in adv
Vikas
As below
You can also create "like for like" flag, that will flag same period across all years, so we don't need to create a flag for each year separately
TempDate as tDate
,year(TempDate) as YEAR
,month(TempDate) as MONTH
,Date(TempDate-0) as d_Date
,InYearToDate(TempDate, maxdate,0,1)*-1 as CY_YTD
, InMonthToDate(TempDate, maxdate ,0)*-1 as CY_MTD
,InYearToDate(TempDate, maxdate,-1,1)*-1 as PY_YTD
,InMonthToDate(TempDate, addyears(maxdate,-1),0)*-1 as PY_MTD
,if(TempDate>=MonthStart(maxdate,-3),1,0) as CY_Last3Month
,if(TempDate>=MonthStart(maxdate,-12),1,0) as CY_Last12Month
,if(TempDate>=MonthStart(addyears(maxdate,-1),-3) and TempDate<=MonthStart(addyears(maxdate,-1)),1,0) as PY_Last3Month
,if(TempDate>=MonthStart(addyears(maxdate,-1),-12) and TempDate<=MonthStart(addyears(maxdate,-1)),1,0) as PY_Last12Month
,if(month(TempDate)<=month(maxdate) and day(TempDate)<=day(maxdate),1,0) as lfl_YTD // will flag same period across all years
,if(month(TempDate)=month(maxdate) and day(TempDate)<=day(maxdate),1,0) as lfl_MTD // will flag same period across all years
Usage
Thanks Vineeth