Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
aamaninanneboin
Contributor
Contributor

KPI with MTD and PMTD.

Hi All, 

I have done MTD and PMTD in a KPI. The issue here is for an example i have data from 03-01-2019 to 04-15-2019.  I would like to see under MTD the data should be visible with the dates of 04-01-2019 to 04-15-2019. 

In PMTD i would like to see 03-01-2019 to 03-15-2019 data. which means if MTD has data of 15 days the same 15 days data of previous month needs to be visible. 

Please do help me out with the solution. 

 

Thanks.

 

 

6 Replies
Shubham_Deshmukh
Specialist
Specialist

Use these expressions : 

MTD =MonthStart(Today()) // 1 Apr 19
PMTD = AddMonths(MonthStart(Today()),-1) // 1 Mar 19 , =AddMonths(Today(),-1) // 15 Mar 19 Today = today() // 15 Apr 19

Shubham

aamaninanneboin
Contributor
Contributor
Author

Thank You Shubham for your reply!

My need is not exactly April 1 and 15.  In MTD it needs to calculate data from April 1st to today's  data and in the same in PMTD also that needs to be done like March 1st to March 16th. 

If MTD is giving 20 days of data then, PMTD also needs to give me last month 20 days of data. 

I have written an expression but that is just giving me MTD data till the data and PMTD full month data. 

Expression:

MTD- sum({<MONTH={$(=(MAX(MONTH)))}>}[Unique Visitors])

PMTD: SUM({<MONTH={$(=Month(AddMonths(Max(MONTH),-1)))}>}[Unique Visitors])

I am getting output in April month dates from 04-01 to 04-015 and in PMTD 03-01 to 03-31.  But i need is if in April month if i have data of 15 days then in March also the same 15 days data needs to be visible. if MTD has 7 days of data then PMTD also needs to be visible only 7 days of data. 

Please help me out, how to write an expression for that. 

Thanks,

Aamani

 

 

 

OtavioCLP
Partner - Contributor
Partner - Contributor

Hi!

So for this problem, you need a variable with the max date and ignore the date fields that can be selected.  

See exemples:

MTD - (04-01 / 04-15)

MTD.PNG

PMTD - (03-01 / 03-15) 

PMTD.PNG

aamaninanneboin
Contributor
Contributor
Author

Thanks for your reply!

I have tried your expression, it is giving me the date if i create a variable but not in set analysis expression and not sure where i am missing. 

VDATE  =Monthstart((VMONTH),-1)  (OUTPUT = 03/01/2019)

VDATE1  =Date(ADDMONTHS((VMONTH),-1)) (OUTPUT = 03/15/2019)

and my VMONTH expression is Max(MONTH)

my set analysis expression is (sum({<$ [Month-Qlik Dates] ={>=$(=VDATE)<=$(=VDATE1)}>}[Unique Visitors])). 

I am not getting the output. Please do help me out. 

 

OtavioCLP
Partner - Contributor
Partner - Contributor

Try

• VMONTH = Max(MONTH)

Sum({$<Date=,Month=,Year=,Date={">=$(=Monthstart($(VMONTH),-1))<=$(=Date(ADDMONTHS($(VMONTH),-1)))"}>}[Unique Visitors] )