cancel
Showing results for
Did you mean:
cancel
Showing results for
Did you mean:

SOLVED
Highlighted
Regular Member

## Use vlookup over a vector?

In the attached image (from Mathcad Prime 3.1) I'm able to use vlookup with a single value. Is it possible to use it with a vector of input values and return a vector of values?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

## Re: Use vlookup over a vector?

I guess thats only possible if you define an auxiliary user function.

Here are two examples. The first hast the data matrix and the return column hardcoded in the function, the second is more generic.

Both function can be called with a single, scalar argument as well. So you may give them a more meaningful name and use them as vlookup replacement (if you only are interested in the fist find),

3 REPLIES 3
Highlighted

## Re: Use vlookup over a vector?

I guess thats only possible if you define an auxiliary user function.

Here are two examples. The first hast the data matrix and the return column hardcoded in the function, the second is more generic.

Both function can be called with a single, scalar argument as well. So you may give them a more meaningful name and use them as vlookup replacement (if you only are interested in the fist find),

Highlighted

## Re: Use vlookup over a vector?

Thanks Werner, as long as the order of shapes matches the look up matrix, your second solution works perfectly.

Why can't a vector be placed directly into the vlookup?

Highlighted

## Re: Use vlookup over a vector?

@dsochor wrote:

Thanks Werner, as long as the order of shapes matches the look up matrix, your second solution works perfectly.

No sure what you mean by that matching order??

Why can't a vector be placed directly into the vlookup?

Because vlookup already has a matrix argument. If the first argument is a matrix/vector, too, you would only be able to vectorize the call if both arguments are of the very same dimension.

But even if that would be the case and you vectorize, Mathcad would cycle through BOTH matrices and so would feed vlookup with a scalar as second argument and this would make vlookaup fail, because the second argument must be a matrix.

So just this (rather useless) example works:

Announcements