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

Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X

Lookup value

SFares
13-Aquamarine

Lookup value

Hello,

 

In Mathcad prime, when a value is looked up from an Excel sheet, the output will be placed in a square bracket , I assume it is an array. When I use the looked it up value and compare it with another value, it gives an error saying it must be a scalar. What do I need to do to the looked up value to make it a scalar?

 

Thanks,

Sam

 

 

 

ACCEPTED SOLUTION

Accepted Solutions
Werner_E
25-Diamond I
(To:SFares)

Lookup will always return an array because its quite possible that more than one value fulfills the condition given. So you also get a 1x1 array if just one single entry applies.

You may choose the very first entry in the list by adding the matrix index 0 (assuming that ORIGIN=0)

Werner_E_0-1695325229410.png

 

You may also consider to use a user-written lookup function, placed somewhere at the top of the sheet (maybe in a collapsed region) which does that job:

Werner_E_0-1695325635232.png

Thanks to the try,,,on error it will not throw an error if no match was found but returns a NaN (or change to whatever you feel appropriate).

Unfortunately user functions can't have an optional argument. So if you need the lookup function with the optional fourth argument you would have to use a second user function

Werner_E_1-1695325770373.png

 

 

View solution in original post

2 REPLIES 2
Werner_E
25-Diamond I
(To:SFares)

Lookup will always return an array because its quite possible that more than one value fulfills the condition given. So you also get a 1x1 array if just one single entry applies.

You may choose the very first entry in the list by adding the matrix index 0 (assuming that ORIGIN=0)

Werner_E_0-1695325229410.png

 

You may also consider to use a user-written lookup function, placed somewhere at the top of the sheet (maybe in a collapsed region) which does that job:

Werner_E_0-1695325635232.png

Thanks to the try,,,on error it will not throw an error if no match was found but returns a NaN (or change to whatever you feel appropriate).

Unfortunately user functions can't have an optional argument. So if you need the lookup function with the optional fourth argument you would have to use a second user function

Werner_E_1-1695325770373.png

 

 

SFares
13-Aquamarine
(To:Werner_E)

Thank you Werner!

Announcements

Top Tags