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: 
BernardBernoulli
Contributor III
Contributor III

Comparison between a week and its former week

Hello.

i wanted to write a simple expression with set analysis which compares a field with a weeknumber per entry with its former week.
So basically I have a table like this:

Week | Article | Amount

11       |  item1 | 10

10       | item 1 | 20

Now i want to put out the difference between these two amounts in another column and wrote something like this:

{<Week= {Week}>}Amount - {<Week= {lastWeek}>}Amount

But this only puts out the difference to the former week if its a positive amount, I'd also like to know if the amount in week 11 was less than in 10, like above in the table, it's negative amount difference.

What am I missing?

(Please note that I created the "lastWeek" field in the load script as following:
[Week] - 1 as lastWeek

 

Labels (3)
2 Replies
TheoAtragie
Partner - Specialist
Partner - Specialist

Hello,

You can try this :
sum({<Week= {Week}>}Amount) - sum({<Week= {lastWeek}>}Amount)


BernardBernoulli
Contributor III
Contributor III
Author

Hey there,

thanks for the reply. 
I tried that before, but this will give me 0 values in every row though.