Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
rupaliqlik
Creator
Creator

YTD,MTD QTD compare with previous year

Hi,

I want to  compare data current year with previous year.want to see YTD,MTD,QTD in straigh chart.And formulae should be write in Set Analysis.

Please help me to get this.

Thanks in advance,

RuE

 

 

Labels (3)
2 Replies
Taoufiq_Zarra

Hi Rue,

Assume that we will use the expression to calculate sales.
and that you have modeled the date dimension with each line is represented by a PeriodID, Year, Quarter, Month, Period.
then the Times variables will be as follows :

YTD (Year-To-Date) : Sum({$<PeriodID = {"<=$(=Max(PeriodID))"},Year = {$(=Max(Year))},Quarter = ,Month = ,Period = >} Sales)

QTD (Quarter-To-Date) Sum({$<PeriodID = {"<=$(=Max(PeriodID))"},QuarterID = {$(=Max(QuarterID))},Year = ,Quarter = ,Month = ,Period = >} Sales)

MTD (Month-To-Date)  Sum({$<PeriodID = {$(=Max(PeriodID))},Year = ,Quarter = ,Month = ,Period = >} Sales)

Current Year-To-Date versus the same period last year

(Sum({$<PeriodID = {"<=$(=Max(PeriodID))"}, Year ={"$(=Max(Year))"}, Quarter = , Month = , Period = > } [Sales)

/

Sum({$<PeriodID = {"<=$(=Max(PeriodID) - 12)"}, Year ={"$(=Max(Year) - 1)"}, Quarter = , Month = , Period = > } Sales))

-1

the same for Current month versus same month last year or Current month versus previous month, ...

NB:

PeriodID: 201901,201902,201903....

Year:2019

Month:Jan,Feb,Mar,...

Quarter:Q1,Q2,Q3;Q4

 

Taoufiq

 

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉
Brett_Bleess
Former Employee
Former Employee

Rue, did Taoufiq's post help you with things?  If it did, be sure to circle back to the thread and use the Accept as Solution button on his post to give him credit for the assistance and let other Community Members know this worked for you. 

I do have a Design Blog post that may be of some further help too:

https://community.qlik.com/t5/Qlik-Design-Blog/Year-over-Year-Comparisons/ba-p/1462927

If you are still needing assistance, leave an update.

Regards,
Brett

To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question.
I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.