Forum Discussion

danh7's avatar
danh7
Copper Contributor
Dec 05, 2023
Solved

Is there a way to complete the below without manually doing it?

Hi,   I'm looking to find an easier, faster and more efficient way to complete the example below. Is there a formula that can help me with this? So I have three rows, as follows, with the formula I...
  • djclements's avatar
    Dec 06, 2023

    danh7 If you have Excel for MS365, try the following formula in cell A3, then drag it across:

     

    =SUMPRODUCT($A$1:A1, SORTBY($A$2:A2, COLUMN($A$2:A2), -1))

     

    The SORTBY function is used to reverse the order of the second row. The SUMPRODUCT function sums the results of multiplying row 1 with row 2 in reverse order.

     

    If you want to accomplish the same thing using a single-cell dynamic array formula, the MAKEARRAY function can be used with CHOOSECOLS and SEQUENCE:

     

    =LET(
    arr, A1:I2,
    MAKEARRAY(1, COLUMNS(arr), LAMBDA(r,c,
       SUMPRODUCT(
          CHOOSECOLS(TAKE(arr,1), SEQUENCE(c)),
          CHOOSECOLS(DROP(arr,1), SEQUENCE(c,,c,-1))))))

     

    Please see the attached workbook, if needed...

Resources