Your post is very confusing, are you saying you wish to average the four 5's, which would be 5. Please explain if not.
Can we also see a debug after the file node.
Also best to post code as text as no one can copy the text from an image.
To take the string
You can pass it through a change node and apply the JSONata expression
Output would be 5
$sum($split($trim($$.payload), /\s/).$number($)) / 6
output would be 3.3333˙
Thanks for the reply and I apologize if I did not make myself understood, however the solution you have proposed is fine
"$ sum ($ split ($ trim ($$. payload), /\s/).$number($)) / 6"
I just wanted to know if it was possible to have an integer as a solution for example:
if the result is this "3.3333333333333335" I want this "3" as output otherwise if I get "3.6666666" as output I would like to have this "4"
If you look at Numeric functions · JSONata You will see all functions you can apply to a number
$round() round depending on decimal place
$ceil() round up
$floor() round down
$round($sum($split($trim($$.payload), /\s/).$number($)) / 6)
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.