Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
kunkumnaveen
Specialist
Specialist

ytd funtion

hello all ,i was going through few of our community posts ,where i found this statement ,please can anyone explain me how does it works and the agenda for this statment thank you

Sum(if(InYearToDate([Invoice Date], MakeDate($(=Max(InvoiceYear)), Month(Today()), Day(Today())), 0), Sales))

1 Reply
sunny_talwar

This statement is just checking if invoice date comes under the max year's today's day and month, then sum sales.

For example if you have data like this:

Invoice DateInvoice YearSales
02/03/2015201520
05/07/2015201530
10/10/2014201410
12/30/2015201520

The InYeartoDate will evaluate like this (Max(Invoice Year) = 2015

Invoice DateInYearToDate([Invoice Date], MakeDate($(=Max(InvoiceYear)), Month(Today()), Day(Today())), 0)
02/03/2015-1 (True)
05/07/2015

-1 (True)

10/10/20150 (False)
12/30/20150 (False)

So the

Sum(If(InYearToDate([Invoice Date], MakeDate($(=Max(InvoiceYear)), Month(Today()), Day(Today())), 0), Sales) = 50

I hope this helps. To learn about InYearToDate() function see the below screenshot from QlikView's help page:

Capture.PNG