Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
joep_026
Contributor III
Contributor III

Multiple rules in formula

Hello all,

 

I have a question regarding multiple rules in 1 formula. This is the line:

sum({$<WEEK= {">=$(CURRENTWEEK)"} ,WEEK= {" <=$(TARGETWEEK)"}, YEAR = {"$(LASTYEAR)"}>}SALES)

Now, as you can see I want the sales of last year from this week untill the target week (which is week 46). So I want the sales between week 32 and 46 of last year. Using this formula now,  I get both the sales of greater than week 32 and smaller than 46, but it adds up both of the values, so the value is too high.

 

I was wondering if there is a way to fix this, maybe using something as the AND formula.

 

I'm looking forward to hearing from you!

Labels (3)
1 Solution

Accepted Solutions
tm_burgers
Creator III
Creator III

Your formula is <= / >=

Which includes the week you are referring to. If you want to exclude the target week just use <

You can also simplify 

sum({$<WEEK= {">=$(Current Week) <$(TARGETWEEK)"}, YEAR = {"$(LASTYEAR)"}>}SALES)

 

Don't need to refer to week twice. 

View solution in original post

2 Replies
tm_burgers
Creator III
Creator III

Your formula is <= / >=

Which includes the week you are referring to. If you want to exclude the target week just use <

You can also simplify 

sum({$<WEEK= {">=$(Current Week) <$(TARGETWEEK)"}, YEAR = {"$(LASTYEAR)"}>}SALES)

 

Don't need to refer to week twice. 

joep_026
Contributor III
Contributor III
Author

Thank you! It works.