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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

help with expression

Please help with my expression.

I am trying to get a sum of previous year to date sales.

if(date([INVC DATE])=yeartodate([INVC DATE],-1),SUM([TOT AMT]), 0)

Once i get this right I will make it a flag in my Load but for now I am testing it as an expression





Any help is much appreciated

Labels (1)
1 Solution

Accepted Solutions
johnw
Champion III
Champion III

I believe you just need to switch the if() to inside the sum():

sum(if(yeartodate([INVC DATE],-1),[TOT AMT]))

View solution in original post

5 Replies
mike_garcia
Specialist
Specialist

I believe you dont need to make a comparison, just use:

if(yeartodate([INVC DATE],-1),SUM([TOT AMT]), 0)


Regards,

Mike.

Miguel García
Qlik Expert, Author and Trainer
boorgura
Specialist
Specialist

Hey,

do you want to try this:

if(year2date([INVC DATE], -1), sum(TOT AMT), 0)

Not applicable
Author

Neither suggestions worked. Both outputted 0 but I have data ranging four years.

johnw
Champion III
Champion III

I believe you just need to switch the if() to inside the sum():

sum(if(yeartodate([INVC DATE],-1),[TOT AMT]))

Not applicable
Author

Works with this, thanks John!