cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

apoc.coll.runningTotal

Avi
Node Clone

Newb to Neo4j, I was successfully able to leverage apoc.coll.avg , apoc.coll.min & apoc.coll.Max but I'm receiving an error when trying to use apoc.coll.runningTotal

WITH apoc.coll.runningTotal([1,2,3,4,5]) AS d RETURN d

Unknown function 'apoc.coll.runningTotal' (line 2, column 6 (offset: 18)) "WITH apoc.coll.runningTotal([1,2,3,4,5]) AS d"

2 ACCEPTED SOLUTIONS

It looks like it does not recognize that function.  I would ask if you have apoc installed, but you said you successfully used the collection's min and max functions. Try running the following query to see if the apoc.coll.runningTotal function is in the list. 

show procedures where name starts with 'apoc'

 

View solution in original post

that is a bummer.  I created a cypher expression that will calculate the runningTotal for you. Here it is in an example. Use the expression on line 2 for calculating it.

with [1,2,3,5,10] as coll
with [i in range(1,size(coll)) | reduce(s=0,x in coll[..i]|s+x)] as runningTotal
return runningTotal

View solution in original post

12 REPLIES 12

I copied and pasted your one line into neo4j browser and it worked.

Screen Shot 2022-10-13 at 4.50.02 PM.png

First, thank you!
Not sure what am I missing.

Avi_0-1665695393378.png

 

It looks like it does not recognize that function.  I would ask if you have apoc installed, but you said you successfully used the collection's min and max functions. Try running the following query to see if the apoc.coll.runningTotal function is in the list. 

show procedures where name starts with 'apoc'

 

You are correct,

It's appear that apoc.coll.runningTotal is not part of the list

Avi_0-1665762233807.png

 

 

There are two versions of the APOC jar.  One is a 'full' version and one is a 'core' version. I switched mine to 'core' and did not see the procedure in the list. Look in your plug-ins folder.  The jar's name has 'core' in it. 

If you have the core, I think you can remove it from the plug-ins folder and install the full version with the Neo4j Desktop under the 'plugins' tab. 

Oops...My mistake. apoc.coll.runningTotal is a function. As such, you need to execute the following query for functions:

show Functions where name contains 'apoc.coll'

I replaced my full version with the 'core' jar.  The functions exists in the 'core' jar as well, so this can't be the issue. 

Sorry, but I do recall a couple of people having similar issues with apoc. Maybe try a reinstalling apoc.

Thanks a bunch! I currently using  Neo4j through Aura and per the support team it's not supported. Do you recommend me to use another neo4j flavor?  Once again I'm a newb to Neo4j.

that is a bummer.  I created a cypher expression that will calculate the runningTotal for you. Here it is in an example. Use the expression on line 2 for calculating it.

with [1,2,3,5,10] as coll
with [i in range(1,size(coll)) | reduce(s=0,x in coll[..i]|s+x)] as runningTotal
return runningTotal

This is awesome! thank you for taking the time.
greatly appreciate. 

You could also check your apoc version with `RETURN apoc.version() AS output;`
FWIW it's working for me on 4.4.0.6

My version is "4.4.0.9".

Nodes 2022
Nodes
NODES 2022, Neo4j Online Education Summit

All the sessions of the conference are now available online