-
Notifications
You must be signed in to change notification settings - Fork 121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add XLOOKUP without support for non standard match_mode and search_mode - and returning values/arrays instead of ranges #1414
Add XLOOKUP without support for non standard match_mode and search_mode - and returning values/arrays instead of ranges #1414
Conversation
43b3afa
to
384bcb8
Compare
b001b7b
to
08445d1
Compare
Thank you for signing the CLA and sharing the pull request. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very solid implementation. Thanks a lot, @selimyoussry. We appreciate that you invested your time to contribute to the HyperFormula.
It requires polishing and probably some of the limitations you described can be addressed to make the function more robust, but it's a good starting point and certainly the right direction to go about implementing the XLOOKUP function.
@@ -227,6 +227,7 @@ Total number of functions: **{{ $page.functionsCount }}** | |||
| ROW | Returns row number of a given reference or formula reference if argument not provided. | ROW([Reference]) | | |||
| ROWS | Returns the number of rows in the given reference. | ROWS(Array) | | |||
| VLOOKUP | Searches vertically with reference to adjacent cells to the right. | VLOOKUP(Search_Criterion, Array, Index, Sort_Order) | | |||
| XLOOKUP | The XLOOKUP function searches a range or an array, and then returns the item corresponding to the first match it finds. If no match exists, then XLOOKUP can return the closest (approximate) match. Current limitations: only default match_mode and search_mode are supported, a range of value is returned, not a range, so having XLOOKUP(...):XLOOKUP(...) will not work. | XLOOKUP(lookup_value, lookup_array, return_array, [if_not_found], [match_mode], [search_mode]) | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can understand why you put it here, but the current convention in HyperFormula is to describe the limitations of the built-in functions in pages https://hyperformula.handsontable.com/guide/list-of-differences.html (difference in results from other spreadsheets) and https://hyperformula.handsontable.com/guide/known-limitations.html#nuances-of-the-implemented-functions (general limitations).
@@ -232,6 +232,7 @@ const dictionary: RawTranslationPackage = { | |||
WEEKNUM: 'HAFTASAY', | |||
WORKDAY: 'İŞGÜNÜ', | |||
'WORKDAY.INTL': 'İŞGÜNÜ.ULUSL', | |||
XLOOKUP: 'ÇAPRAZARA', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for providing the translations. We really appreciate it.
* @param ast | ||
* @param state | ||
*/ | ||
public xlookup(ast: ProcedureAst, state: InterpreterState): InterpreterValue { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very solid implementation 💪
Merging this PR into a local branch to fine-tune the implementation. Thank you, @selimyoussry, for the contribution. |
Thank you again for your input, @selimyoussry, and for spending your time improving HyperFormula. I'm glad to see the new function added in HF v3. Thank you! |
Context
Per this discussion it seems like XLOOKUP is useful to a bunch of people. It is to for me at the very least :) and so I am happy to contribute to its implementation!
How did you test your changes?
I have tested the XLOOKUP implementation against the examples from Microsoft's official doc
Types of changes
Related issues:
Checklist: