LAMBDA to subtract previous cumulative values

ExcelToDAX

Board Regular
Joined
Feb 9, 2023
Messages
207
Office Version
  1. 365
Platform
  1. Windows
If I am given the following values in Cells A1:A10, how can I create a LAMBDA function to get the Expected Output that is shown in Column B? Column C has the formulas for Column B, but I want to create a LAMBDA spill function so that I don't have to drag the formula.

1723225757755.png
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Not a lambda, but a spiller. I broke it into more steps then it needed to be in, but it is clearer.

MrExcelPlayground23.xlsx
AB
1DataOutput
2580140580140
31220346640206
41872330651984
52821861949531
63616416794555
74434962818546
85137115702153
95889631752516
106671512781881
Sheet15
Cell Formulas
RangeFormula
B2:B10B2=LET(a,A2:A10,b,VSTACK(0,a),c,DROP(b,-1),a-c)
Dynamic array formulas.


Or just:

=A2:A10-DROP(VSTACK(0,A2:A10),-1)
 
Upvote 1
Solution
Also:
=IFERROR(A2:A10-A1:A9,A2)

Book1
AB
1DataOutput
2580140580140
31220346640206
41872330651984
52821861949531
63616416794555
74434962818546
85137115702153
95889631752516
106671512781881
Sheet1
Cell Formulas
RangeFormula
B2:B10B2=IFERROR(A2:A10-A1:A9,A2)
Dynamic array formulas.
 
Upvote 0
T202408a.xlsm
ACD
1DataOutputOutput
2580,140580,140580,140
31,220,346640,206640,206
41,872,330651,984651,984
52,821,861949,531949,531
63,616,416794,555794,555
74,434,962818,546818,546
85,137,115702,153702,153
95,889,631752,516752,516
106,671,512781,881781,881
11
1a
Cell Formulas
RangeFormula
C2:C10C2=A2:A10-N(+A1:A9)
D2:D10D2=Differential(A2:A10)
Dynamic array formulas.
Lambda Functions
NameFormula
Differential=LAMBDA(rngNums,rngNums-DROP(VSTACK(0,rngNums),-1))
 
Upvote 0

Forum statistics

Threads
1,221,519
Messages
6,160,282
Members
451,635
Latest member
nithchun

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top