Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
Coming your way, the Qlik Data Revolution Virtual Summit. October 27-29. REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Specialist
Specialist

YTD

Hi,

what is the script to get YTD (Year Till Date)?

YTD 13-14

YTD 12-13 and so on

e.g As today is 11 Dec,

YTD 12-13 means (01 April 12) to (11 Dec 13)

YTD 13-14 means( 01 April 13) to (11 Dec 14)

pick data for this time interval

7 Replies
Highlighted
Creator III
Creator III

Hi Tyagi,

YTD can be calculated in different way, depend about your data model.

Usually I use set analysis with a field date.

An example in attachment

Regards

Luca Jonathan Panetta

Highlighted
Not applicable

if you want calculate YTD sales then use the YeartoDate function to create the YTD flag

YeartoDate( DateField , 0 ,4) AS YTDFlag

Highlighted
Specialist
Specialist

Thanks Panetta,

Its very helpful answer.

On Fri, Dec 12, 2014 at 8:08 PM, Panetta Luca Jonathan <

Highlighted
Not applicable

also check  inyeartodate

Highlighted
MVP & Luminary
MVP & Luminary

Hi,

Try like this

=Sum({<YearDimension=, QuarterDimension=, MonthDimension=, DateDimension={'>=$(=YearStart(Today(), 0, 4))<=$(=Today())'}>} Sales)

The above expression will you the Sales for the YTD.

Note: Replace YearDimension, QuarterDimension, MonthDimension and DateDimension with your actual dimension names.

Regards,

Jagan.

Highlighted
Specialist
Specialist

Hi dathu,

Thanks for you answer.

But I have no idea, How to use flag

Highlighted
MVP & Luminary
MVP & Luminary

Hi,

If you need in script then try like this

Data:

LOAD

*,

If(YearToDate(DateDimension, 0, 4), 1, 0) AS YTDFlag

FROM DataSource;

Hope this helps you.

Regards,

Jagan.