简体   繁体   中英

How to combine nested array formulas in google sheets?

My dataset is as follows

在此处输入图像描述

Tokens per week is a static value, basically, it is hardcoded

Stakes per week is a sum of values in a column below. Eg. F2 contains formula: =sum(F4:F)

Values in calls below Week # are manually typed.

What I need is to calculate how many tokens each user has earned per week and show total amount in a row under Tokens pending

An example of Math for a very first row:

F4/F2*F1+G4/G2*G1

I have users constantly signing up for this campaign, so I need a formula to automatically apply for each new user.

Here is what I tried so far:

  1. I put following formula in E4: =ArrayFormula(if(isblank(A4:A), "", (SUMIF(IF(COLUMN(F4:BE4),ROW(F4:BE)),ROW(F4:BE),F4:BE)*($F$1/$F$2)-SUMIF(IF(COLUMN(BF4:BO4),ROW(BF4:BO)),ROW(BF4:BO),BF4:BO))))

    But that gives me wrong results

  2. I put following formula in E4 =arrayformula(sum(iferror(F4:BE4/F$2:BE$2*F$1:BE$1,0)))

    But that calculates it correctly for only one row. Formula is not automatically applied for each row below

  3. I put following formula into E4: =ArrayFormula(if(isblank(A4:A), "", arrayformula(sum(iferror(F4:BE/F$2:BE$2*F$1:BE$1,0)))))

    But that gives me the wrong calculations again.

I am now considering to write user-defined function to handle this case.

I would appreciate any help!

UPDATE 25-06-2020

Here is a link to the sheet as it was requested:

try in F2:

=ARRAYFORMULA(IF(F1:1="",,TRANSPOSE(MMULT(TRANSPOSE(
 INDIRECT("F4:"&ROWS(A:A))*1), SIGN(F4:F)^0))))

and E4:

=ARRAYFORMULA(MMULT(IFERROR(F4:BE/F2:BE2*F1:BE1, 0), TRANSPOSE(SIGN(F1:BE1))^0))

0

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM