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

Announcements
Save an extra $150 Dec 1–7 with code CYBERWEEK - stackable with early bird savings: Register
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Expression for calculating YTD

Hi all,

I have a calendar date data and want to calculate YTD over it. I am having highest date in it as '01-Aug-2015' so, I am considering that as my current date. I had used following expression for calculating the YTD:

'=sum({1 <CalendarDate= {">= YearStart(GetFieldSelections(CalendarDate)) <= $(=max(CalendarDate))"}>} sale)'

and if I passed a date as '01-Jun-2013', it brought me data for sale from '01-Apr-2012' i.e. the first date in my data to '01-Jun-2013' which, it should actually bring from '01-Jun-2013' to '01-Aug-2015' (highest date in my data).

So, I reversed the operators between dates in the above expression such as:

=sum({1 <CalendarDate= {"<= YearStart(GetFieldSelections(CalendarDate)) >= $(=max(CalendarDate))"}>} BSLAMC)

This gave me the data from '01-Jun-2013' to '01-Aug-2015' and I want it from '01-Jan-2013' to '01-Aug-2015'.

I don't  understand where I am going wrong.

Any help would be greatly appreciated!

Thanks,

Madhura

11 Replies
Not applicable
Author

Gysbert,

I so much interpreted it wrongly. Thanks for clearing things! And am so sorry about causing so much confusion. Also, the previous expression works in that case whereas, this one gives data onwards the selected date. Both usable according to requirements.

Many Thanks!

jagan
Partner - Champion III
Partner - Champion III

Try like this

sum({1 <CalendarDate= {"<=$(=max(CalendarDate))"}>} sale)


Regards,

Jagan.