Using math to figure out average values from Webflow CMS

Hi community,

I am trying to use an HTML embed with the CMS to work out the average values of a field and use this value to affect the width of a div. I’ve included some images below to assist in this.

There is also another technicality that I would like to implement where the code filters out entries depending on another field’s value. As there are 3 different ‘Ambition #’ numbers, I would like the code to collect each one independently.

The simple line of code that I currently have in the HTML embed only takes the highest value of the ‘Progress %’ field so I need to use maths to figure out the average value and output this, however I do not know how to write this!

Any help would be greatly appreciated, thank you!