Skip to content

Instantly share code, notes, and snippets.

@peterneubauer
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save peterneubauer/9363884 to your computer and use it in GitHub Desktop.
Save peterneubauer/9363884 to your computer and use it in GitHub Desktop.

A sales funnel

CREATE (s:Stage{name:'Suspect'})
CREATE (mql:Stage{name:'Marketing Qualified Lead'})
CREATE (ssc:Stage{name:'Self-Serve Customer'})
CREATE (ec:Stage{name:'Existing Customer'})
CREATE (ecno:Stage{name:'Existing Customer-No Opportunity'})
CREATE (sql:Stage{name:'Sales Qualified Lead'})
CREATE (nc:Stage{name:'No change'})
CREATE (r:Stage{name:'Recycled'})
CREATE (ro:Stage{name:'Reached Out'})
CREATE (dbd:Stage{name:'Disqualified Bad Data'})
CREATE (e:Stage{name:'Engaged'})
CREATE (sdr:Stage{name:'New SDR Lead'})

CREATE (:Path{name:'P1', count:159})-[:START]->(s)-[:NEXT_P1]->(mql)-[:NEXT_P1]->(ssc)
CREATE (:Path{name:'P2', count:4})-[:START]->(s)-[:NEXT_P2]->(ssc)
CREATE (:Path{name:'P3', count:9})-[:START]->(mql)-[:NEXT_P3]->(ec)-[:NEXT_P3]->(ecno)

What are the different paths through my sales funnel?

MATCH (path)-[:START]->(startStage), p=(startStage)-[r*0..]->(endStage)
WHERE ALL(rel in rels(p) WHERE type(rel) = type(head(r)))
RETURN path, p as funnel, type(head(rels(p))) as type, length(p) as length
ORDER BY length(p) desc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment