TEXT Function: Difference between revisions
From Planfix
No edit summary |
No edit summary |
||
Line 23: | Line 23: | ||
*TEXT({{Task.Number field}};"d") - result: 12 | *TEXT(<nowiki>{{Task.Number field}}</nowiki>;"d") - result: 12 | ||
*TEXT({{Task.Number field}};"05d") - result: 00012 | *TEXT(<nowiki>{{Task.Number field}}</nowiki>;"05d") - result: 00012 | ||
*TEXT({{Task.Number Field}};"04.3f") - result: 0012.340 | *TEXT(<nowiki>{{Task.Number Field}}</nowiki>;"04.3f") - result: 0012.340 | ||
*TEXT({{Task.Number field}};".4f") - result: 12.3400 | *TEXT(<nowiki>{{Task.Number field}}</nowiki>;".4f") - result: 12.3400 | ||
Examples: | ''Examples:'' | ||
TEXT(A;".3f") | TEXT(A;".3f") | ||
Line 39: | Line 37: | ||
TEXT(1234567; ",.2f") - result: 12 345,67 | TEXT(1234567; ",.2f") - result: 12 345,67 | ||
Revision as of 05:56, 11 December 2019
The TEXT function formats numbers according to a given format. For example, if column A contains the number 23.7825 and you need to format it to three decimal places, you would use
TEXT(A;".3f")
As a result, you'd get the string "23.782".
Format:
TEXT(number;string_format)
String format:
The string format is written as follows: [flags][width][.precision]conversion
- [flags] — special symbols for formatting. For example, the "+" flag means that the numeric value must include the + symbol; the "-" flag means the result should be left-justified; and the "," flag sets the thousands separator for integers. It is not mandatory.
- [width] — A positive decimal integer that defines the minimum number of characters to be displayed. It is not mandatory.
- [.precision] — non-negative integer with a decimal point before it. Usually used to limit the number of characters. It is not mandatory.
- conversion — a symbol that indicates how the number should be formatted. You can use d for whole numbers, f for floats. This is mandatory.
As an example, let's say we have the number 12.34 in a field called "Number field."
- TEXT({{Task.Number field}};"d") - result: 12
- TEXT({{Task.Number field}};"05d") - result: 00012
- TEXT({{Task.Number Field}};"04.3f") - result: 0012.340
- TEXT({{Task.Number field}};".4f") - result: 12.3400
Examples:
TEXT(A;".3f")
TEXT(Template:Task.Number field;".3f")
TEXT(1234567; ",.2f") - result: 12 345,67