Skip to content

Instantly share code, notes, and snippets.

@jexp
Forked from peterneubauer/salesfunnel.adoc
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 jexp/9364329 to your computer and use it in GitHub Desktop.
Save jexp/9364329 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})-[:NEXT_P1]->(s)-[:NEXT_P1]->(mql)-[:NEXT_P1]->(ssc)
CREATE (:Path{name:'P2', count:4})-[:NEXT_P2]->(s)-[:NEXT_P2]->(ssc)
CREATE (:Path{name:'P3', count:9})-[:NEXT_P3]->(mql)-[:NEXT_P3]->(ec)-[:NEXT_P3]->(ecno)

What are the different paths through my sales funnel?

MATCH p=(startStage:Path)-[r]-()-[rels*0..]->(endStage)
WHERE ALL(rel in rels WHERE type(rel) = type(r))
WITH startStage, type(r) as type, max(length(p)) as max, collect(p) as paths
RETURN startStage, type, head([p in paths WHERE length(p) = max]) as longest_path
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment