Skip to main content
Solved

Calculating the weighted average


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

 

Best answer by stevendasilva

@Johannes_Strobe 

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

View original
Did this topic help you find an answer to your question?

3 replies

stevendasilva
  • Inspiring
  • 30 replies
  • Answer
  • November 11, 2023

@Johannes_Strobe 

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


  • Author
  • Participating Frequently
  • 5 replies
  • November 11, 2023

Hi @stevendasilva ,

 

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

stevendasilva

@Johannes_Strobe  Awesome, nice work.


Reply