You need to sign in to do that
Don't have an account?
Sylvio Avilla
Compare Records
Hello Everyone,
I kindly ask for some help from the experts, regarding the following problem:
I need is somehow get all records with the same date (DATE) and subtract the field B from field A of the next record.
After that, create at least 2 variables, the first with the biggest value ( VAR 1 = Record 3.ID ) and so on (VAR 2 = Record 1.ID , VAR 3 = Record 2. ID).
I've made an example that I think will be easier to understand!
Does anyone can help whit that?
Thanks
I kindly ask for some help from the experts, regarding the following problem:
I need is somehow get all records with the same date (DATE) and subtract the field B from field A of the next record.
After that, create at least 2 variables, the first with the biggest value ( VAR 1 = Record 3.ID ) and so on (VAR 2 = Record 1.ID , VAR 3 = Record 2. ID).
I've made an example that I think will be easier to understand!
Date | A | B | Opp | Result | Sort | |
Record 1 | 1/1/10 | 10 | 20 | =B1-A2 | 20 | Var 2 |
Record 2 | 1/1/00 | 40 | 50 | =B2-A3 | 10 | Var 3 |
Record 3 | 1/1/00 | 60 | 70 | =B3-A1 | 60 | Var 1 |
Record 4 | 2/1/00 | 10 | 20 | |||
Record 5 | 2/1/00 | 30 | 40 | |||
Record 6 | 2/1/00 | 60 | 70 |
Does anyone can help whit that?
Thanks
Let me know if this helps.
All Answers
You need something like this.
2) loop your list with a while, and substract VarA[i+1] - VarB[i] and add the result to a new list.
3) sort that new list (newlist.sort() ) and create a loop to change the order of the list (the method always returns ascending order), you can see an example here: https://developer.salesforce.com/forums/?id=906F000000091wIIAQ
I will try doing that.
It worked perfect, thanks! Just one more thing: How could I get the ID from the 2 values?
Based on the example:
myValue = 60 Id1= Record3 and Id2= Record2
@Dixit, your answer also helped me, thank you too. Unfortunately, I can only choose one!
Let me know if this helps.
Thank you again LBK!