Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

m_perreault
Contributor II

Prior Year MTD and QTD Sales

Hi All

I have the set analysis

Sum({<Year=,Month=,DateKey={">=$(=Num(MonthStart(Max(DateKey))))<=$(=Max(DateKey))"}>}[Sales Amount])

to calculate my Current Year month to date sales but want to now calculate my Prior Year MTD Sales and am having difficulty.

Same with QTD.

Thank you

Tags (1)
2 Replies
md_qlikview
Contributor II

Re: Prior Year MTD and QTD Sales

Hi,

Try below method in set expression for Prior MTD

=SUM({<Year={'$(vPriorYear)'},Month={'$(vMaxMonth)'},Day={'<=$(vMaxDay)'},Date=,MonthYear=>}Amount)

vPriorYear - =vMaxYear -1

vMaxMonth      =month(max(Date))

vMaxDay        =day(max(Date))

mov
Esteemed Contributor III

Re: Prior Year MTD and QTD Sales

MTD:

Sum(if(InMonthToDate(DateKey,today(),0),[Sales Amount]))

Prior Year MTD:

Sum(if(InMonthToDate(DateKey,today(),-12),[Sales Amount]))

QTD:

Sum(if(InQuarterToDate(DateKey,today(),0),[Sales Amount]))

Prior Year QTD:

Sum(if(InQuarterToDate(DateKey,today(),-4),[Sales Amount]))

Community Browser