I am trying to figure out how to find the average of the last 4 columns. Every column in yellow Fame
is the score, and then Attacks
is how many attacks used to get that score.
So essentially, it would need to add up the last 4 Fame
columns, and divide it by the sum of the last 4 Attacks
columns.
Example
For the first row (row 3), the final output would do this calculation:
(3500 2700 3250 3300) / (16 12 16 16) = 212.5
Example 2
For the second row (row 4), the final output would do this calculation:
(2850 3500) / (16 16) = 198.4
Any help is greatly appreciated! Thanks!
CodePudding user response:
try:
=SUM(SPLIT(REGEXEXTRACT(TEXTJOIN(" ", 1, FILTER(D3:3,
MOD(COLUMN(D3:3), 2)=0)), "\d \d \d \d $"), " "))/
SUM(SPLIT(REGEXEXTRACT(TEXTJOIN(" ", 1, FILTER(D3:3,
MOD(COLUMN(D3:3)-1, 2)=0)), "\d \d \d \d $"), " "))
CodePudding user response:
ALTERNATIVE SOLUTION:
Looking at your examples, you seem to have specific conditions in getting the last 4 or 2 columns of Fame
& Attacks
on your sheet. Perhaps you can try this custom Google Sheet function below via scripting.
Sample Sheet:
Demonstration:
- Placed the custom sheet function called
last4CellsAvrg
on cellN3
to get all the calculations on every row.NOTE: There is another way to use the custom function
- Another way is by using a single range like this sample below (
=last4CellsAvrg(D4:M4)
) to only get the row 4 calculation: