Skip to content
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

clarify interpretation of less and greater as before/after #461

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions help/en/docs/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,18 @@ Table.lookupRecords(..., order_by=("Foo", "Bar")).find.le(foo, bar)

If the `find` attribute is shadowed by a same-named user column, you may use `_find` instead.

> :warning: In the following methods, "less" is best understood as "before"
> and "greater" is best understood as "after".
> For example, if you use a negative `order_by` on a simple integer column,
> then the meaning of less than and greater than will be flipped.

The methods available are:

- __`lt`__: (less than) find nearest record with sort values < the given values
- __`le`__: (less than or equal to) find nearest record with sort values <= the given values
- __`gt`__: (greater than) find nearest record with sort values > the given values
- __`ge`__: (greater than or equal to) find nearest record with sort values >= the given values
- __`eq`__: (equal to) find nearest record with sort values == the given values
- __`lt`__: (less than) find nearest (last) record with sort values < (before) the given values
- __`le`__: (less than or equal to) find nearest record with sort values <= (last before or first equal) the given values
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should actually be "last that's before or equal" -- if you have multiple equal values to the one you are looking up, it should return the last of these.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to edit this PR to so the phrasing is more accurate. I was just pointing out that it wasn't clear to without these details. If it feels cleaner to you, maybe you could these alternative explanations somewhere else and link to that.

- __`gt`__: (greater than) find nearest (first) record with sort values > (after) the given values
- __`ge`__: (greater than or equal to) find nearest (first) record with sort values >= (equal or after) the given values
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one should be "first equal or after", though I think this is clear as is. Maybe le can be phrased the same way.

- __`eq`__: (equal to) find nearest (first) record with sort values == the given values

Example from [our Payroll template](https://templates.getgrist.com/5pHLanQNThxk/Payroll).
Each person has a history of pay rates, in the Rates table. To find a rate applicable on a
Expand Down