Hi guys, I am relatively new at coding with Velo.
I am trying to calculate the average value of all fields with ID #fieldOne of the current product in a dataset. I’m not sure if the calculation is already wrong, or I’m just having an error reading the result.
My text field “#textOutput” which should represent the average value, shows so currently only “[object Object]”.
wixData . aggregate ( “dataset” )
. filter ( filter ) //filter by the current product
. avg ( “fieldOne” ) //get average of all fields from fieldOne
. run ()
. then ( ( result ) => { let avgFieldValues = result . items ;
$w ( “#textOutput” ). text = “” + avgFieldValues ; //put average value to textOutput
} )