# Calculating the weighted average

Topic Labels: Formulas
Solved
1154 3
cancel
Showing results for
Did you mean:
5 - Automation Enthusiast

Hello,

how can I calculate the weighted average?

Example:
[-4, 0, 2, 0] -> I get this values via a roolup
I want the result to be -2 i.g.. Correct me please if I am wrong.

I'm open to use multiple formulas.

Best regards
Johannes

1 Solution

Accepted Solutions
6 - Interface Innovator

Just to confirm are you looking for the average but only if the result is not 0?

If yes this has been solved over here:
https://community.airtable.com/t5/formulas/excluding-zero-values-from-an-average-rollup/td-p/26312

3 Replies 3
6 - Interface Innovator

Just to confirm are you looking for the average but only if the result is not 0?

If yes this has been solved over here:
https://community.airtable.com/t5/formulas/excluding-zero-values-from-an-average-rollup/td-p/26312

5 - Automation Enthusiast

thanks. I already saw the post. While reading the message more closely, I found out that it actually is the solution for my problem. However, there is no example, so I didn't figure it out the first time.

My solution was to return BLANK() instead of a 0, when the Formula encountered a BLANK() at the first or second value. If this is done, the AVERAGE() function of the Rollup skips these values.

Example:
• Values is the first table:
• Data: The data are either blanks or numbers from 1 to infinite. They represent "bad" and "good" occurrences.
• Formula: IF(AND({👍}=BLANK(), {👎}=BLANK()), BLANK(), IF({👍}=BLANK(),-{👎},IF({👎}=BLANK(),{👍},{👍}/({👎}+{👍}))))
•
• Rollup in the other table: IF(COUNTA(values)!=0, AVERAGE(values), BLANK())

Best regards
Johannes
6 - Interface Innovator

@Johannes_Strobe  Awesome, nice work.