0

I am creating a net-worth calculator in Excel. I am planning to enter the bank and equity details once a week. I want to know the change in my portfolio compared to the last entry using a function. I can write a VBA code to search for the previous value for a particular category but I want to know if XLookup or something else can help me.

I want a formula for column Diff. I tried the below formula but it gives me the first or the current matching row and I need the previous one.

=XLOOKUP(E42;E:E;I:I;;;-1)

enter image description here

2
  • 4
    Your problem is the entire column references E:E and I:I. You want a mixed reference like E$2:E2 that expands as you drag down. Commented Aug 7, 2024 at 14:04
  • 1
    Alternatively, can spill it with dynamic array formula: =MAP(B2:B7,E2:E7,LAMBDA(α,δ, IFERROR(δ-XLOOKUP(α,DROP(B2:α,-1),DROP(E2:δ,-1),,,-1),0))) Commented Aug 7, 2024 at 15:07

1 Answer 1

1

As @BigBen said - you need a combination of absolute and relative referencing:
=IFERROR(E2-XLOOKUP(B2;$B$1:B1;$E$1:E1;;;-1);"") < add this to cell F2 in the below image and drag down.

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.