Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

sum two maximum from the start

Hello everyone !

I have a list with sales date in this format (eliminating the time, so there are recurring dates) and the sales.

DateSale
31-07-2015
10
31-07-2015
11
03-08-2015
12
03-08-2015
12
04-08-2015
5
04-08-2015
9
05-08-2015
15
06-08-2015
8
07-08-2015
8
10-08-2015
3
10-08-2015
20
10-08-2015
9

I want to make a line graph showing me the sum of the two highest sales since the beginning of time starting from the first date. Thus becomes:

DateSale
31-07-2015
21
03-08-2015
24
04-08-2015
24
05-08-2015
27
06-08-2015
27
07-08-2015
27
10-08-2015
35

I have tried many "measures" to make this graphic but no results. Any suggestions?

Regards !

13 Replies
sunny_talwar

It seems to be working, isn't it?

Capture.PNG

Not applicable
Author

Yes Sunny !

It seems to be working perfectly, the part of "Rangesum( FirstSortedValue(Sale, -Sale- recID/100000,1), FirstSortedValue(Sale, -Sale- recID/100000,2))" its amazing.


However, I dont understand -Sale- recID/100000.

I've been all afternoon trying to apply the function to another problem and I could not. Can you explain me ?


Sorry for your time Sunny, I am new in this.

Thank you very very much.

swuehl
MVP
MVP

The second argument -Sale-recID/100000 is the sort weight for the Sales field. It's used to distinguish between ties, i.e. in your sample between the repeated values of 12.

We somehow need QV to find '12' as max number, but also '12' as second largest number in your series of values, e.g. on 03-08-2015.

So I've added a small unique number, record number divided by 100000. (the added number should be much smaller than the smallest difference between your Sale values).

Hope this makes sense,

Stefan

Not applicable
Author

Thank you very much Stefan

Thank you for your explanations and time!