Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
anthony-gb
Contributor II
Contributor II

Expression to only sum if in current year

I am trying to implement an expression to limit the amount only where the due_date is in the current year. I also only want to sum amounts > 0

I have tried many variations of this eg.

if(year(due_date) = year(today()) and amount > 0, sum(amount))

any help would be appreciated

Labels (3)
1 Solution

Accepted Solutions
Or
MVP
MVP

You've got the right syntax, just the wrong way around. Your conditions go inside the sum rather than vice versa, since you  need them re-evaluated for each row.

Sum(If(Year(due_date)=year(Today()) AND amount>0,amount)

View solution in original post

2 Replies
Or
MVP
MVP

You've got the right syntax, just the wrong way around. Your conditions go inside the sum rather than vice versa, since you  need them re-evaluated for each row.

Sum(If(Year(due_date)=year(Today()) AND amount>0,amount)

anthony-gb
Contributor II
Contributor II
Author

ugh, of course! thanks