Difference between revisions of "Documentation/How Tos/Calc: HLOOKUP function"
From Apache OpenOffice Wiki
< Documentation | How Tos
OOoWikiBot (Talk | contribs) m (Robot: Automated text replacement %s) |
|||
(2 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | + | {{Documentation/MasterTOC | |
+ | |bookid=1234''' | ||
+ | |booktitle=<div style="padding: 8px; font-size: 140%; font-weight: bold; background-color: #9BC0F5;">CALC FUNCTIONS</div> | ||
+ | |ShowParttitle=block|parttitle=[[Documentation/How_Tos/Calc:_Spreadsheet_functions|<div style="font-size: 140%;">Spreadsheet Functions]] | ||
+ | |ShowNextPage=block|NextPage=Documentation/How_Tos/Calc:_INDEX_function | ||
+ | |ShowPrevPage=block|PrevPage=Documentation/How_Tos/Calc:_CHOOSE_function | ||
+ | |ShowPrevPart=block|PrevPart=Documentation/How_Tos/Calc:_Number_Conversion_functions | ||
+ | |ShowNextPart=block|NextPart=Documentation/How_Tos/Calc:_Statistical_functions | ||
+ | |toccontent= <div style="padding: 4px; font-size: 130%; font-weight: hidden; background-color:#DCE9FC;">FUNCTIONS</div> | ||
+ | |||
+ | <div style="font-size: 140%; border-style: outset outset outset none; border-color:#DCE9FC;">Spreadsheet Lookup functions</div> | ||
+ | * [[Documentation/How_Tos/Calc:_ADDRESS_function|<div style="font-size: 120%;">Address]] | ||
+ | * [[Documentation/How_Tos/Calc:_CHOOSE_function|<div style="font-size: 120%;">Choose]] | ||
+ | * [[Documentation/How_Tos/Calc:_HLOOKUP_function|<div style="font-size: 120%; border-style: double; border-color:#778899;">Hlookup]] | ||
+ | * [[Documentation/How_Tos/Calc:_INDEX_function|<div style="font-size: 120%;">Index]] | ||
+ | * [[Documentation/How_Tos/Calc:_INDIRECT_function|<div style="font-size: 120%;">Indirect]] | ||
+ | * [[Documentation/How_Tos/Calc:_LOOKUP_function|<div style="font-size: 120%;">Lookup]] | ||
+ | * [[Documentation/How_Tos/Calc:_MATCH_function|<div style="font-size: 120%;">Math]] | ||
+ | * [[Documentation/How_Tos/Calc:_OFFSET_function|<div style="font-size: 120%;">Offset]] | ||
+ | * [[Documentation/How_Tos/Calc:_VLOOKUP_function|<div style="font-size: 120%;">Vlookup]] | ||
+ | |||
+ | <div style="font-size: 140%; border-style: outset outset outset none; border-color:#DCE9FC;">Spreadsheet Information functions</div> | ||
+ | * [[Documentation/How_Tos/Calc:_AREAS_function|<div style="font-size: 120%;">Areas]] | ||
+ | * [[Documentation/How_Tos/Calc:_COLUMN_function|<div style="font-size: 120%;">Column]] | ||
+ | * [[Documentation/How_Tos/Calc:_COLUMNS_function|<div style="font-size: 120%;">Columns]] | ||
+ | * [[Documentation/How_Tos/Calc:_ERRORTYPE_function|<div style="font-size: 120%;">Errortype]] | ||
+ | * [[Documentation/How_Tos/Calc:_INFO_function|<div style="font-size: 120%;">Info]] | ||
+ | * [[Documentation/How_Tos/Calc:_ROW_function|<div style="font-size: 120%;">Row]] | ||
+ | * [[Documentation/How_Tos/Calc:_ROWS_function|<div style="font-size: 120%;">Rows]] | ||
+ | * [[Documentation/How_Tos/Calc:_SHEET_function|<div style="font-size: 120%;">Sheet]] | ||
+ | * [[Documentation/How_Tos/Calc:_SHEETS_function|<div style="font-size: 120%;">Sheets]] | ||
+ | |||
+ | <div style="font-size: 140%; border-style: outset outset outset none; border-color:#DCE9FC;">Other functions</div> | ||
+ | * [[Documentation/How_Tos/Calc:_DDE_function|<div style="font-size: 120%;">Dde]] | ||
+ | * [[Documentation/How_Tos/Calc:_HYPERLINK_function|<div style="font-size: 120%;">Hyperlink]] | ||
+ | * [[Documentation/How_Tos/Calc:_STYLE_function|<div style="font-size: 120%;">Style]] | ||
+ | }}__TOC__ | ||
== HLOOKUP == | == HLOOKUP == | ||
Line 71: | Line 107: | ||
*The case sensitivity behaviour is discussed in [http://qa.openoffice.org/issues/show_bug.cgi?id=71000 issue 71000] | *The case sensitivity behaviour is discussed in [http://qa.openoffice.org/issues/show_bug.cgi?id=71000 issue 71000] | ||
− | {{ | + | {{SeeAlso|EN| |
* [[Documentation/How_Tos/Calc: CHOOSE function|CHOOSE]] | * [[Documentation/How_Tos/Calc: CHOOSE function|CHOOSE]] | ||
* [[Documentation/How_Tos/Calc: INDEX function|INDEX]] | * [[Documentation/How_Tos/Calc: INDEX function|INDEX]] | ||
Line 87: | Line 123: | ||
* [[Documentation/How_Tos/Calc: Functions listed alphabetically|Functions listed alphabetically]] | * [[Documentation/How_Tos/Calc: Functions listed alphabetically|Functions listed alphabetically]] | ||
* [[Documentation/How_Tos/Calc: Functions listed by category|Functions listed by category]]}} | * [[Documentation/How_Tos/Calc: Functions listed by category|Functions listed by category]]}} | ||
− | [[Category: Documentation/Reference/Calc]] | + | [[Category: Documentation/Reference/Calc/Spreadsheet functions]] |
Latest revision as of 09:20, 17 July 2018
Contents
HLOOKUP
Returns a value from a table row, in the column found by lookup in the first row.
Syntax:
HLOOKUP(lookupvalue; datatable; rowindex; mode)
- lookupvalue is a value (number, text or logical value) to look up in the top row of the range/array datatable. When a value is matched in the top row, HLOOKUP returns the corresponding value (in the same column) in the rowindex^{th} row of datatable, where rowindex = 1 is the top row.
- If mode is 0 or FALSE, the top row of datatable may be unordered, and the first exact match is found (searching left to right).
- If mode is 1 or TRUE, or is omitted, the top row of datatable must be sorted, with numbers in ascending order appearing before text values in alphabetic order. HLOOKUP decides where in the top row lookupvalue would appear. If there is an exact match, that is the column found; if there is more than one exact match, the column found is not necessarily the leftmost. If there is no exact match, the column to the left of where value would appear in the top row is found; the #N/A error results if that column is not in the table.
- If regular expressions are enabled on the Tools - Options - OpenOffice.org Calc - Calculate dialog, HLOOKUP will find exact matches treating lookupvalue as a * regular expression. This only makes sense, and should only be used, if mode is 0 or FALSE.
- If 'Search criteria = and <> must apply to whole cells' is enabled on the Tools - Options - OpenOffice.org Calc - Calculate dialog, lookupvalue must match the whole text in the cell; if not, it can match just part of the text.
- Matching is always case-insensitive - the case setting on the Tools - Options - OpenOffice.org Calc - Calculate dialog does not apply.
Examples:
In these examples, cells A1, B1, C1, D1, E1 contain 3, 5, cat, mat, matter, and cells A2, B2, C2, D2, E2 contain A, B, C, D, E.
HLOOKUP(3; A1:E2; 2; 0)
- returns A. Cell A1 in the top row matches 3. The contents of the corresponding cell on the 2^{nd} row (that is, A2) are returned. The top row happens to be sorted, but this is not necessary in mode 0.
HLOOKUP(4; A1:E2; 2; 0)
- returns #N/A. There is no match for 4.
HLOOKUP("CAT"; A1:E2; 2; 0)
- returns C. The difference between lower and upper case is ignored, so CAT matches cat.
HLOOKUP("c.t"; A1:E2; 2; 0)
- returns C if regular expressions are enabled (and #N/A if not). The dot '.' stands for 'any single character' in a regular expression, so c.t matches cat.
HLOOKUP(".at"; A1:E2; 2; 0)
- returns C if regular expressions are enabled. cat matches; so does mat, but the leftmost match is always found in mode 0.
HLOOKUP("at"; A1:E2; 2; 0)
- returns #N/A if 'Search criteria = and <> must apply to whole cells' is enabled and C otherwise. at does not match any whole cell contents, but it matches part of cat.
HLOOKUP(3; A1:E2; 2; 1)
- returns A. Cell A1 in the top row matches 3. The top row must be sorted in mode 1, with text coming after numbers. matter follows mat because although the first letters are the same, matter has more letters.
HLOOKUP(4; A1:E2; 2; 1)
- returns A. 4 would appear between 3 and 5 in the top row, so the position to the left is found.
HLOOKUP(1; A1:E2; 2; 1)
- returns #N/A. 1 would appear before 3 in the top row, and there is no position to the left of that in the table.
HLOOKUP(7; A1:E2; 2; 1)
- returns B. 7 would appear between 5 and cat in the top row, so the position to the left is found.
HLOOKUP("apple"; A1:E2; 2; 1)
- returns B. apple would appear between 5 and cat in the top row, so the position to the left is found.
HLOOKUP("mate"; A1:E2; 2; 1)
- returns D. mate would appear between mat and matter in the top row, so the position to the left is found.
HLOOKUP("rat"; A1:E2; 2; 1)
- returns E. rat would appear after matter in the top row, so the position to the left is found.
HLOOKUP("at"; A1:E2; 2; 1)
- returns B, even if 'Search criteria = and <> must apply to whole cells' is disabled. In this case the match between at and cat is ignored in favour of treating at as a word to come between 5 and cat.
Issues:
- The case sensitivity behaviour is discussed in issue 71000
See Also