Updates to Grist Functions (#125)

Clarify documentation for QUOTIENT, SUMPRODUCT, UUID, REPLACE, lookupOne, lookupRecords, and $group.
This commit is contained in:
Natalie Misasi
2022-02-12 23:38:24 -06:00
committed by GitHub
parent ec7bc9bef3
commit 2611d05c39
4 changed files with 39 additions and 19 deletions

View File

@@ -550,7 +550,7 @@ def PRODUCT(factor1, *more_factors):
def QUOTIENT(dividend, divisor):
"""
Returns one number divided by another.
Returns one number divided by another, without the remainder.
>>> QUOTIENT(5, 2)
2
@@ -797,7 +797,8 @@ def SUMIFS(sum_range, criteria_range1, criterion1, *args):
def SUMPRODUCT(array1, *more_arrays):
"""
Multiplies corresponding components in the given arrays, and returns the sum of those products.
Multiplies corresponding components in two equally-sized arrays,
and returns the sum of those products.
>>> SUMPRODUCT([3,8,1,4,6,9], [2,6,5,7,7,3])
156
@@ -859,7 +860,13 @@ def TRUNC(value, places=0):
return ROUNDDOWN(value, places)
def UUID():
"""Generate a random UUID-formatted string identifier."""
"""
Generate a random UUID-formatted string identifier.
Since UUID() produces a different value each time it's called, it is best to use it in
[trigger formula](https://support.getgrist.com/formulas/#trigger-formulas) for new records.
This would only calculate UUID() once and freeze the calculated value. By contrast, a regular [formula]
may get recalculated any time the document is reloaded, producing a different value for UUID() each time.
"""
if six.PY2:
return str(uuid.UUID(bytes=[chr(random.randrange(0, 256)) for _ in xrange(0, 16)], version=4))
else: