Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
vikasmahajan

YTD/MTD/QTD/Rolling 3/Rolling 12 months in filter pane Qlik Sense

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

 

 

Hope this resolve your issue.
If the issue is solved please mark the answer with Accept as Solution & like it.
If you want to go quickly, go alone. If you want to go far, go together.
Labels (1)
11 Replies
vinieme12
Champion III
Champion III

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

qlikCommunity1.PNG

 

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
vikasmahajan
Author

Thanks Vineeth

Hope this resolve your issue.
If the issue is solved please mark the answer with Accept as Solution & like it.
If you want to go quickly, go alone. If you want to go far, go together.