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)
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.