Formulas (Notion): verschil tussen versies
Naar navigatie springen
Naar zoeken springen
k (Jeroen Strompf heeft pagina Formules (Notion) hernoemd naar Formulas (Notion)) |
|||
(8 tussenliggende versies door dezelfde gebruiker niet weergegeven) | |||
Regel 1: | Regel 1: | ||
+ | An overview of Notion functions. | ||
+ | == concat() == | ||
− | == | + | Concatenate strings, including output from commands. E.g.: |
+ | |||
+ | <pre> | ||
+ | concat("Created: ", formatDate(prop("Time - Created"), "W")) | ||
+ | </pre> | ||
+ | |||
+ | This probably isn't a very useful example, as it includes a label in the property field - Excellent way to mess up data integrity. | ||
+ | |||
+ | == format() == | ||
+ | |||
+ | ''Format'' is the oppositie of ''toNumber'': Convert something to a string. Example: | ||
+ | |||
+ | <pre> | ||
+ | slice(format(12345),2,2)) | ||
+ | </pre> | ||
+ | |||
+ | == slice() == | ||
+ | |||
+ | ''slice'' is like ''mid$(string,positie,length)'' in some other languages | ||
+ | |||
+ | === Syntaxis === | ||
+ | |||
+ | <pre> | ||
+ | slice(string, start-index [, end-index]) as string | ||
+ | |||
+ | * start-index: Starting at 0 | ||
+ | * end-index (option): Last character to include | ||
+ | </pre> | ||
+ | |||
+ | === Examples === | ||
+ | |||
+ | [[Task IDs (Notion)]]: | ||
+ | <pre> | ||
+ | # Strings of 9 digits | ||
+ | # Remove first 6 digits | ||
+ | # | ||
+ | slice(format(toNumber((prop("Created time"))/10000),5) | ||
+ | </pre> | ||
+ | |||
+ | === Sources === | ||
+ | |||
+ | * https://learn.thomasjfrank.com/notion-formula-reference/formula-components/functions/slice | ||
+ | |||
+ | == toNumber() == | ||
+ | |||
+ | You need <code>toNumber()</code> for calculations that involve ''relations'': Eventhough the looked-up value might be a number, it isn't as it is a ''relation''. Example: | ||
+ | |||
+ | <pre> | ||
+ | toNumber(prop("Product unit price")) * prop("Number of products") | ||
+ | </pre> | ||
+ | |||
+ | Also use this function to convert a date-/time field to Unix Epoch Time: | ||
+ | |||
+ | <pre> | ||
+ | toNumber(prop("Created time")) | ||
+ | </pre> | ||
+ | |||
+ | == See also == | ||
+ | |||
+ | * [[Task IDs (Notion)]] | ||
+ | |||
+ | == Sources == | ||
* https://www.notion.so/help/formulas | * https://www.notion.so/help/formulas | ||
+ | * https://www.notion.vip/formulas/ |
Huidige versie van 18 feb 2023 om 20:09
An overview of Notion functions.
concat()
Concatenate strings, including output from commands. E.g.:
concat("Created: ", formatDate(prop("Time - Created"), "W"))
This probably isn't a very useful example, as it includes a label in the property field - Excellent way to mess up data integrity.
format()
Format is the oppositie of toNumber: Convert something to a string. Example:
slice(format(12345),2,2))
slice()
slice is like mid$(string,positie,length) in some other languages
Syntaxis
slice(string, start-index [, end-index]) as string * start-index: Starting at 0 * end-index (option): Last character to include
Examples
# Strings of 9 digits # Remove first 6 digits # slice(format(toNumber((prop("Created time"))/10000),5)
Sources
toNumber()
You need toNumber()
for calculations that involve relations: Eventhough the looked-up value might be a number, it isn't as it is a relation. Example:
toNumber(prop("Product unit price")) * prop("Number of products")
Also use this function to convert a date-/time field to Unix Epoch Time:
toNumber(prop("Created time"))