SOLVED

vlookup in stockhistory table

Copper Contributor

hi all,

i want to create a sheet that follows some stocks and tells me every stock when it was at the highes price since it was added to the sheet. for that i'm using vlookup that works on a table from "stockhistory" function. somehow instead of getting the real date of the max price, i get the latest date. i used "evaluate formula" to try debugging what's wrong. the vlookup reached the table correctly but didnt fit between the max value to its date and i dont know why. i'm adding the debugging window.197282036_837814776816217_3414105826048912022_n.png197450678_905382646708468_804537938393458325_n.png

7 Replies
best response confirmed by allyreckerman (Microsoft)
Solution

@fidtal 

As variant

=INDEX(E2#,XMATCH(1e10,INDEX(E2#,,2),-1),{1,2})

on

image.png

will it work without physically showing the table?
it returns the last row again...

@fidtal 

Yes

image.png

=LET(stock,STOCKHISTORY("msft",TODAY()-90,TODAY(),0,2,0,3),INDEX(stock,XMATCH(10000000000,INDEX(stock,,2),-1),{1,2}))

@fidtal 

Could you please share the file with the sample?

@Sergei Baklan 

the solution of index and xmatch works. didnt understand exactly how... andi dont know why vlookup didnt work

@fidtal 

With XMATCH() we find position of max looking for any big number and returning position of it or next smaller number which will be our max. INDEX() returns data on this position.

 

Why doesn't VLOOKUP() work - hard to say without the sample.

1 best response

Accepted Solutions
best response confirmed by allyreckerman (Microsoft)
Solution

@fidtal 

As variant

=INDEX(E2#,XMATCH(1e10,INDEX(E2#,,2),-1),{1,2})

on

image.png

View solution in original post