-1
MATCH (ORG:ORG)-[ORGHASPROBLEM:HAS]->(PROBLEM:PROBLEM) WITH PROBLEM,

extract(NUM IN filter( V IN collect({ PROB1:PROBLEM.PROB_ID, PROB2:PROBLEM.REGION}) where V.PROB2= 'LONDON') | NUM.PROB1) AS MEASURES1,

extract(NUM IN filter( V IN collect({ PROB1:PROBLEM.PROB_ID, PROB2:PROBLEM.REGION}) where V.PROB2= 'PARIS') | NUM.PROB1) AS MEASURES2

unwind MEASURES1 AS RESULT1
unwind MEASURES2 AS RESULT2

RETURN DISTINCT PROBLEM.SLAB AS DIMENSION,count(RESULT1) AS  MEASURES1,count(RESULT2) AS MEASURES2

I am uploading the image of the database and expected output. Can anybody rewrite the query or tell me where I am going wrong?

My question is that MEASURES1 and MEASURES2 have my required data. When I am using the unwind MEASURES1 AS RESULT1 it give the output as required, but in case of the 2nd unwind (unwind MEASURES2 AS RESULT2) it removes the entire data from MEASURES1 and MEASURES2.

Please, see the attached image to understand the scenario more clearly.

Data model, expected output

Charlotte Skardon
  • 6,220
  • 2
  • 31
  • 42
Akshay Vakharia
  • 79
  • 1
  • 12
  • 2
    Please avoid sentences as "please reply quickly" and focus on [how to create a minimal, complete and verifiable example](https://stackoverflow.com/help/mcve). – Fabio Lamanna Aug 16 '17 at 09:08
  • Please stop trying to ask specific users for help. All assistance is voluntary. – ChrisF Aug 16 '17 at 12:34
  • Your query has syntax errors: `Invalid input '‘': expected whitespace, comment or an expression (line 3, column 100 (offset: 169)) "extract(NUM IN filter( V IN collect({ PROB1:PROBLEM.PROB_ID, PROB2:PROBLEM.REGION}) where V.PROB2= ‘LONDON’) | NUM.PROB1) AS MEASURES1,"` – Bruno Peres Aug 16 '17 at 14:27
  • @Bruno Peres done with syntax error – Akshay Vakharia Aug 16 '17 at 14:49
  • 1
    I believe that is a good idea to put a Cypher query in your question to create a initial data set and the expected result over this data set. – Bruno Peres Aug 16 '17 at 14:51

1 Answers1

0

The follow query will get the data out of the database in a way that will allow you to build your report. As a bonus it will also work if you add a new region :

MATCH (p:PROBLEM)
WITH count(*) AS ct, p.REGION AS pregion, p.SLAB AS slab
RETURN slab, collect({region: pregion,  count: ct}) as result;

Hope this helps.

Regards, Tom

Tom Geudens
  • 2,638
  • 9
  • 15