Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
05-14-2020 02:45 PM
Hi.
I'm new in neo4j and i have a question that i've already tried to solve but nothing.
So, i'm doing a graph and at certain point i have to sum values that i have in a json file, but the value of the field is in string. Here's what i have:
Solved! Go to Solution.
05-14-2020 04:58 PM
Ok nice, it worked. It has converted to float. But how do i sum those values? Just have to put: return sum(tofloat(replace(replace(C.Preco,".",""),",","."))) ?
05-14-2020 04:00 PM
Hello,
I think it's not working since in your string there is a "." and a ",".
So you can try to replace the "." and after convert your number to a float.
You can do like this:
toFloat(replace(C.Preco, ".", ""))
05-14-2020 04:27 PM
Looks like you are using European number system
Try below
return tofloat(replace(replace(C.Preco,".",""),",","."))
Or visit below for APOC code
https://neo4j.com/docs/labs/apoc/current/mathematical/number-conversions/
05-14-2020 04:58 PM
Ok nice, it worked. It has converted to float. But how do i sum those values? Just have to put: return sum(tofloat(replace(replace(C.Preco,".",""),",","."))) ?
05-14-2020 05:02 PM
Ok, it was like i said: return sum(tofloat(replace(replace(C.Preco,".",""),",",".")))
Thank you very much for your kindness!
Stay safe!
05-14-2020 05:45 PM
Just for u to understand i have this graph:
05-14-2020 08:24 PM
Try below
Match (e1:ENTIDADE) -(c:CONTRATO)->(e2:ENTIDADE)
With e1, sum(tofloat(replace(replace(C.Preco,".",""),",","."))) as sumPreco
Where sumPreco >50000
Return e1 as Entity, sumPreco
05-15-2020 03:07 AM
05-15-2020 03:16 AM
Oh, ok, i tought it would appear the graph and some kind of label in the FraudulentEntities. After i see the tables i've understood that neo4j is returning me only the FraudulentEntities. Thank you friend!
Have a nice day, and stay safe!
All the sessions of the conference are now available online