Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Set Analysis Last 5 sales

Good day. I need to calculate the sum of the last 5 sales when sales were greater than 0

for example should get 19

DateCount
01.01.01

1

02.01.013
03.01.010
04.01.014
05.01.011
06.01.017
07.01.010
08.01.014




9 Replies
sivarajs
Specialist II
Specialist II

 

Use expressions as

sum ({<"Date" ={">$(=max(Date)-5)<=$(=max(Date))"}>}Count)

--Siva

Not applicable
Author

I need to pass the date in which the sale was 0

With your expression result is 9, and I need to get 16

sivarajs
Specialist II
Specialist II

How you are saying 16 can you explain little?

Not applicable
Author

sorry, could not correctly written

Not applicable
Author

corrected first post

For example: From the last date five sales should get 19

sivarajs
Specialist II
Specialist II

This might helps you

sum

({<"Date" ={">=$(=max(Date)-5)<=$(=max(Date))"},Count={">0"}>}Count)

Not applicable
Author

Thanks for the answer, but it is wrong, turn 16, and 19 should

And for example, dates can not go in sequence, ie,

Date           Count

05.12.2010   2

08.12.2010   2

15.12.2010   1

01.01.2011   1

05.01.2011   2

You should now have 8, and in your terms, it considers the last two dates and issue 3

whiteline
Master II
Master II

This works fine, even with user selections:

=Sum({<Date={">=$(=FirstSortedValue({<Count={'>0'}>} total Date, -Date, 5))"}>} Count)

Not applicable
Author

Thanks for the answer, it's something that we should