Forum Discussion

Pravcha's avatar
Pravcha
Copper Contributor
Jan 20, 2025

Formula not working - Dynamic array for subtraction

Currently I'm facing a error with the below formulas, which is giving Error "You have entered too many Argument for this function" or simply "Zero" is coming as output. Hence requesting any SME support to fix this formula and help me to make use in my spreadsheet.

Below few trouble shoots done from my end before publish my concern here:
1. I have ensured there is no blank cells or without values.
2. I'm using MS-excel 365. where few functions in the formula is compatible for my version as mentioned on the internet.

Formula 1:

=IF(COUNTA(BD3:BO3)<1, "", IF(LOOKUP(2,1/(BD3:BO3<>""), BD3:BO3) = LOOKUP(2,1/(BD3:BO3<>""), OFFSET(BD3:BO3, 0, -1)), LOOKUP(2,1/(BD3:BO3<>""), BD3:BO3), INDEX(BD3:BO3, 1) - SUM(FILTER(BD3:BO3, (BD3:BO3<>"") * (BD3:BO3<>OFFSET(BD3:BO3, 0, -1))))) )


Formula 2:

=IF(COUNTA(BD3:BO3)<1, "", LET( LastValue, LOOKUP(2, 1/(BD3:BO3<>""), BD3:BO3), PreviousValue, LOOKUP(2, 1/(BD3:BO3<>""), OFFSET(BD3:BO3, 0, -1)), IF(LastValue = PreviousValue, LastValue, PreviousValue - LastValue) ) )



Formula Purpose Intended:

To dynamically subtract the values from left to right on the last 2 non-empty cells from the given range BD3:BO3 

1. Running Subtraction: Subtract values of last 2 non-empty - Last non-empty cell from the above specified range, it should subtract the last 2 non-empty cell only, whenever the range sequentially get updated with values.

2. Ignore Duplicates: If the value being a duplicate/same in the last 2 non-empty cell, then the subtraction operation should be skipped & the formula should only give the same value in the last non-empty cell.

Please help me to fix this, I have tried multiple measures but still the error persist . I have attached sheet as well.

1 Reply

  • How about this:

     

    =LET(
      rng, FILTER(BD3:BO3, BD3:BO3<>""),
      len, COUNTA(rng),
      last, INDEX(rng, len),
      prev, INDEX(rng, len-1),
      IF(last=prev, last, last - prev)
    )

     

Resources