Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

tyagishaila
Valued Contributor

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
pljsoftware
Contributor III

Re: YTD

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

Not applicable

Re: YTD

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

YeartoDate( DateField , 0 ,4) AS YTDFlag

tyagishaila
Valued Contributor

Re: YTD

Thanks Panetta,

Its very helpful answer.

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

Not applicable

Re: YTD

also check  inyeartodate

MVP
MVP

Re: YTD

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.

tyagishaila
Valued Contributor

Re: YTD

Hi dathu,

Thanks for you answer.

But I have no idea, How to use flag

MVP
MVP

Re: YTD

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.

Community Browser