qie.doTableLookup¶
Signature: qie.doTableLookup(value, notFoundValue, tableName, sourceColumn, targetColumn)
Returns: String result - the result of the table lookup
Queries the sourceColumn of the specified table and returns the corresponding value in targetColumn.
Note
You can match on a single column or on multiple columns.
Note
Matching is case-insensitive.
Note
The same column can be used for both sourceColumn and targetColumn, which is a quick way to confirm that a value exists in the table.
Note
The returned value is not necessarily identical to the value searched for: the table's own spelling wins, so looking up 'abc' in a table that holds 'ABC' returns 'ABC'.
Parameters¶
| Type | Name | Description | Default |
|---|---|---|---|
| String or String[] | value | the value (or values) to look for in 'sourceColumn' | |
| String | notFoundValue | the value to return in the event that 'value' is not found in 'sourceColumn' | |
| String | tableName | the name of the global or local variable (must be a table variable) | |
| String or String[] | sourceColumn | the source column name (or names, if matching on multiple) | |
| String | targetColumn | the target column name |
Example¶
// Examples of doTableLookup
/*
Given a sample table:
+------+-----+--------+
| name | age | state |
+------+-----+--------+
| Bob | 21 | UT |
| Jaime| 43 | CA |
| Tom | 59 | NY |
+------+-----+--------+
*/
// Example: value as String, sourceColumn as String
var jaimesAge = qie.doTableLookup(
"Jaime", // value to search for
"", // default value when no match is found
"myVariableTable", // table variable name
"name", // source column
"age" // target column
); // 43
// Example: value as String[], sourceColumn as String[] (multi-column match)
var tomFromNY = qie.doTableLookup(
["Tom", "NY"], // values to search for
"", // default value when no match is found
"myVariableTable", // table variable name
["name", "state"], // source columns
"age" // target column
); // 59
// Example: notFoundValue used when no match
var unknownAge = qie.doTableLookup(
"Unknown", // value to search for
"N/A", // default value when no match is found
"myVariableTable", // table variable name
"name", // source column
"age" // target column
); // "N/A"
// Example: same source and target column, to confirm the value exists
var knownName = qie.doTableLookup(
"Tom", // value to search for
"", // default value when no match is found
"myVariableTable", // table variable name
"name", // source column
"name" // target column (same as the source column)
); // "Tom"