Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
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.
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.
the year2date function has a yearoffset parameter for that purpose.
try the time chart assistant.
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