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

Announcements
ALERT: QlikView server communication interruptions following Microsoft Windows Domain Controller security updates
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

YTD for previous year

Hello!

I'm trying to create an expression that sums up all the units sold from the beginning of the previous year up to the selected month of that year (Example: the year 2009 and the month April is selected and I want to see the total number of units sold between Jan and April in 2008).

The code below gets me the result of the current year so it seems to be discarding the Year-part of the expression.

This code below gives me the result of the selected month of the previous year so it seems to discard the Month-part of the expression.

sum({<Year={"<=$(=max(Year)-1)"}>}{<Month={"<=$(=min(Month)) >$(=Month(addmonths(max(Month))))"}>} Units)

This code below gives me the result of the selected month of the previous year so it seems to discard the Month-part of the expression.

sum({<Month={"<=$(=min(Month))>$(=Month(addmonths(max(Month))))"}>}{$<Year={$(=max(Year)-1)}>}Units)

I would be very thankful if anyone could help me solve this problem since I have been trying to get this right for a while.

Kind regards Daniel





Labels (1)
1 Solution

Accepted Solutions
Not applicable
Author

hi Daniel,

hope below is what you're looking for:

YTD:

sum({<Year={$(=max(Year))}, Month={"<=$(=max(Month))"}>} Units)


for last year, -1 from the max(Year)

i do not have qlikview on the pc i'm using now so can't really verify the syntax. i'll repost tomorrow if it doesn't help.

View solution in original post

3 Replies
Not applicable
Author

hi Daniel,

hope below is what you're looking for:

YTD:

sum({<Year={$(=max(Year))}, Month={"<=$(=max(Month))"}>} Units)


for last year, -1 from the max(Year)

i do not have qlikview on the pc i'm using now so can't really verify the syntax. i'll repost tomorrow if it doesn't help.

yblake
Partner - Creator II
Partner - Creator II

the year2date function has a yearoffset parameter for that purpose.

try the time chart assistant.

Not applicable
Author

Thank you both very much for your quick replies.

The solution kplow gave me worked exactly as I wanted it to do so once again, a big thanks.

Kind Regards Daniel