Head's Up! Site migration is underway. Phase 2: migrate recent content
β08-09-2022 01:58 PM
I am looking to create a bar chart in NeoDash using Cypher which gives the percentage of each response (r.Response), (Categories are - Accepted, Declined etc.), a property of the [r:RE_INVITED_TO] relationship, broken down by Gender (p.Gender). Here is my current code -
MATCH (p:REPerson)-[r:RE_INVITED_TO]-(:REEvent)
WITH SUM(toInteger(r.Response)) As total
MATCH (p:REPerson)-[r:RE_INVITED_TO]-(:REEvent)
RETURN p.Gender, count(p), 100.0 * SUM(r.Response) / total
Currently it gives me the error message
sum() can only handle numerical values, duration, and null. Got String("Accepted")
How would I fix this?
β08-09-2022 02:49 PM
I think all your values of r.response can not be converted to an integer. I think at least one value is βAcceptedβ
β09-09-2022 12:01 AM
Hi @Kpanton ,
You probably want to use 'response' as a grouping key here and aggregate by count:
RETURN p.Gender as Gender, r.Response, 100.0 * COUNT(r.Response) / total as Percentage
That should give you a result like this - which you can put in a stacked bar chart:
Gender | Response | Percentage |
F | Accepted | 60% |
F | Declined | 40% |
M | Accepted | 30% |
M | Declined | 70% |
All the sessions of the conference are now available online