
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How to calculate YTD amount
Hello,
I don’t manage to calculate YTD amount and it is driving me nuts.
someone who Can help me providing correct syntax?
Expected result 2018 YTD Oct = 320. I have a variable Vlastmonth which returns October.
i always need the YTD for current year (January until last month).
Year, Month, Actuals
2018,jan,100
2018,feb,20
...
2018,Oct,200 (last month)
2018,Nov,200
Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
i.e.
=sum({< ytd_flag = {1}>} measure_value)


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can also check this if you want to use the script option
https://community.qlik.com/t5/QlikView-App-Development/YTD-Year-to-date/td-p/582412

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If your YTD.month is static you could flag your YTD dates i the script.
sum({<YtdFlag = {'1'}>}Actuals)
If you don't have access to the script then you could do the following expression. Assuming that vYtdMonth is a digit 1-12.
sum({< Month= {"<$(vYtdMonth)"}>} Actuals)
If you also want to limit the year you could include a Year modifier
sum({< Year= {"$(=max(Year))"}, Month= {"<$(vYtdMonth)"}>} Actuals)
Qlik Community MVP

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
i.e.
=sum({< ytd_flag = {1}>} measure_value)


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Aggr(RangeSum(Above(Sum([Actuals]),0,RowNo())), (Year, Month, (NUMERIC)))


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can also check this if you want to use the script option
https://community.qlik.com/t5/QlikView-App-Development/YTD-Year-to-date/td-p/582412

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If your YTD.month is static you could flag your YTD dates i the script.
sum({<YtdFlag = {'1'}>}Actuals)
If you don't have access to the script then you could do the following expression. Assuming that vYtdMonth is a digit 1-12.
sum({< Month= {"<$(vYtdMonth)"}>} Actuals)
If you also want to limit the year you could include a Year modifier
sum({< Year= {"$(=max(Year))"}, Month= {"<$(vYtdMonth)"}>} Actuals)
Qlik Community MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I always consider YTD is Year to date only. If My understand is correct I suggest to use this?
Sum({<DateField = {">=$(=YearStart(Max(DateField)))<=$(=AddMonths(MonthEnd(Max(DateField)),-1))"}>} Sales)
Or
Sum({<DateField = {">=$(=Date(YearStart(Max(DateField))),'Your Date Field Format')<=$(=Date(AddMonths(MonthEnd(Max(DateField)),-1)),'Your Date Field Format')"}>} Sales)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks a lot for your support!I used the flag in script, works perfect
