Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
tyagishaila
Specialist
Specialist

YTD Calculation

I want year wise slots,

day and month must be Today's date but Year should not be

e.g.

YTD(11-12)  is 1/1/2011 to 11/12/2012

YTD(12-13) is 1/1/2012 to 11/12/2013

YTD(13-14) is 1/1/2031 to 11/12/2014

This is for sale comparison, if I am comparing my sale today, than last year sale must be compare from start date to till date on last year

otherwise comparison will be wrong.

I think You understand my requirement

1 Solution

Accepted Solutions
Not applicable

Hi Shalia

I think this might give you want you seek (I hope) its basically at a day/date level instead.

Sum({<YourDate = {'$(=Date(Today()))', '$(=Date(AddYears(Today(), -1)))'} >} SalesAmount)

View solution in original post

13 Replies
Not applicable

Hi Shalia,

I've done YTDs like this in the past, I usually have 2 or 3 columns (one per Year for comparison).  The below does this year and last year, for any extra years replace -1 in the second statement with -2 etc for 2012 etc....

Hope this helps

CY: sum({$<Year = {$(=max(Year))}, Month = {"<=$(=max({<Year={$(=max(Year))}>} Month))"}>} Sales)

LY =sum({$<Year = {$(=max(Year-1))}, Month = {"<=$(=max({<Year={$(=max(Year))}>} Month))"}>} Sales)

tyagishaila
Specialist
Specialist
Author

Hi Salvatore,

Thanks for reply, these CY and LY expressions are also helpful.

But its not full fill my requirement, There is no expression for today's date, like 12/12

its important, because we can compare sale of this year to sale of last year to particular date,

we don't have no data of this year after today's date, and we cant compare this year data till 12/12/14 to last year data till 31/12/13.

tyagishaila
Specialist
Specialist
Author

Hi Salvatore,

Thanks for reply, these CY and LY expressions are also helpful.

But its not full fill my requirement, There is no expression for today's date, like 12/12

its important, because we can compare sale of this year to sale of last year to particular date,

we don't have no data of this year after today's date, and we cant compare this year data till 12/12/14 to last year data till 31/12/13.

tyagishaila
Specialist
Specialist
Author

We can do it by using number of days,

as 1 year has total 365 days, than on particular date which day is there,

Like on 28th'Dec there are 362th day of year, we can take till  362th day of last year.

Not applicable

Ah okay, will look into that today for you and come back, cheers

tyagishaila
Specialist
Specialist
Author

ThankYou  so  much Salvatore,

Not applicable

Hi Shalia

I think this might give you want you seek (I hope) its basically at a day/date level instead.

Sum({<YourDate = {'$(=Date(Today()))', '$(=Date(AddYears(Today(), -1)))'} >} SalesAmount)

tyagishaila
Specialist
Specialist
Author

Really very very thanks to you,

As I am not sure because I am not well aware to qlikview.

I think,It takes today's date and same date of last year because of -1.

(Its perfect).

To create same slots of 1 year back, i.e. -2,

I have to do,

Date(Today()))' = Date(AddYears(Today(), -1)

and '$(=Date(AddYears(Today(), -1) = $(=Date(AddYears(Today(), -2) and so

on..

Is am I right or not?

On Fri, Dec 12, 2014 at 4:27 PM, Salvatore Zannino <qcwebmaster@qlikview.com

Not applicable

yes you are correct - you've got it!