Flux query for problem

I am having column name in format - DistPdschMcsInitial.MCSInitial.0.MCSTable.0, DistPdschMcsInitial.MCSInitial.1.MCSTable.0 and so on upto DistPdschMcsInitial.MCSInitial.16.MCSTable.0. I wanted to count the number of values for each field and then apply formula: (0n0+1n1+2*n2+ ---- + 15 * n15) / (n0+n1±-+n15)
where n0,n1 are respective counts for each column.

from(bucket: “atlas”)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r[“_measurement”] == “data”)
|> filter(fn: (r) => r._field =~ /DistPdschMcsInitial.*MCSTable.0/)
|> group(columns:[“_field”])
|> count()

Results for this query is -

Now i am stuck on how to move forward, i thought using findrecord() but not sure how to proceed. Can anybody help me here?

Thanks