Hi: I do have the following scenario:
The challenge is to add a property to each Fruit with one of this options ('TOP','MIDDLE','BOTTOM'). So it would be 'TOP' if they are in the top 30% with the highest weights, ´MIDDLE' in the top 70% highest weights, and 'BOTTOM' for the rest.
So I generate my sample grapgh with this code:
// clear data
MATCH (n)
DETACH DELETE n;
//Create Sample Basket
CREATE (:Fruit {Name: "Pear"})<-[:INCLUDES {Weight: 0.05}]-(b:Basket)-[:INCLUDES {Weight: 0.25}]->(:Fruit {Name: "Apple"}),(:Fruit {Name: "Ananas"})<-[:INCLUDES {Weight: 0.15}]-(b)-[:INCLUDES {Weight
: 0.30}]->(:Fruit {Name: "Peach"}),(b)-[:INCLUDES {Weight: 0.25}]->(:Fruit {Name: "Banana"})
And then I Bring the fruits in the basket ordered by they weight percentage over the basket total.
MATCH (b:Basket)-[i:INCLUDES]-(f:Fruit)
Return f.Name as FruitName, i.Weight as FruitPercent ORDER BY FruitPercent DESC
and I get:
FruitName | FruitPercent |
---|---|
"Peach" | 0.3 |
"Apple" | 0.25 |
"Banana" | 0.25 |
"Ananas" | 0.15 |
"Pear" | 0.05 |
What I do need to produce is this instead:
FruitName | FruitPercent | FruitPercentAccumulated | Category |
---|---|---|---|
"Peach" | 0.3 | 0.3 | 'TOP' |
"Apple" | 0.25 | 0.55 | 'MIDDLE' |
"Banana" | 0.25 | 0.7 | ´MIDDLE' |
"Ananas" | 0.15 | 0.85 | 'BOTTOM' |
"Pear" | 0.05 | 1.00 | 'BOTTOM' |
I have tried many alternatives to generate the accumulated percentage but did not found any that worked, since it requieres to use a calculated variable over the first list. At the end I also want to insert back the atribute Category in every Fruit node with the result value.
The problem I am exposing is a very simplificated example that illustrates what I am really trying to solve which is the ABCFMR Analisys in Logistics.
Thanks in advance for any help!!