Difference between revisions of "Text Concatenation Operator: &"
(Mention of Formatted Text Literals.) |
|||
(3 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
[[category:Operators]] | [[category:Operators]] | ||
[[Category:Doc Status C]] <!-- For Lumina use, do not change --> | [[Category:Doc Status C]] <!-- For Lumina use, do not change --> | ||
+ | {{ReleaseBar}} | ||
− | + | == A & B== | |
− | + | Evaluates «A» and «B», coerces their element values to text, and concatenates the result. | |
− | + | === Concatenating numeric values === | |
+ | When concatenating numeric values to text, a [[number format]] is required to determine how the numbers should be rendered as text, what precision should be depicted, etc. The number format for the variable or [[User-Defined Function]] being evaluated is used. Only the number format for the whole variable is used -- if you have set cell-level formats (such as a different number format for a particular slice), this does not impact the behavior of the number-to-text coercion. If in doubt, you can use the [[NumberToText]] function to control the format of converted numbers before applying the & operator. | ||
− | When concatenating numeric values | + | {{Release|6.0||When you are concatenating numeric values, a ''much'' better option is to use a [[Formatted Text Literal]], which results in a more readable expression and you can easily control the number format.}} |
− | = Examples = | + | == Examples == |
+ | :<code>'Hello' & ' ' & 'world' → 'Hello world'</code> | ||
+ | :<code>5 & 2 → '52'</code> | ||
+ | :<code>['a', 'b'] & 'c' → ['ac', 'bc']</code> | ||
− | + | == Details== | |
− | + | The need to coerce numbers to text using a particular format often arises. Instead of having to rely on setting the number format for the variable that you are defining for this purpose, you can use the [[NumberToText]] function. | |
− | |||
− | |||
− | = | ||
− | |||
− | The need to coerce numbers to text using a particular format often arises. Instead of having to rely on setting the number format for the variable that you are defining for this purpose, | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
+ | == See Also == | ||
* [[JoinText]] | * [[JoinText]] | ||
+ | * [[Concat]] | ||
+ | * [[ConcatRows]] | ||
+ | * [[ConcatN]] | ||
+ | * [[Set_Functions#Function_SetUnion|SetUnion]] | ||
+ | * [[Aggregate]] | ||
+ | * [[NumberToText]] | ||
+ | * [[Text functions]] | ||
+ | * [[Formatted Text Literals]] |
Latest revision as of 20:42, 8 October 2021
Release: |
4.6 • 5.0 • 5.1 • 5.2 • 5.3 • 5.4 • 6.0 • 6.1 • 6.2 • 6.3 • 6.4 • 6.5 • 6.6 |
---|
A & B
Evaluates «A» and «B», coerces their element values to text, and concatenates the result.
Concatenating numeric values
When concatenating numeric values to text, a number format is required to determine how the numbers should be rendered as text, what precision should be depicted, etc. The number format for the variable or User-Defined Function being evaluated is used. Only the number format for the whole variable is used -- if you have set cell-level formats (such as a different number format for a particular slice), this does not impact the behavior of the number-to-text coercion. If in doubt, you can use the NumberToText function to control the format of converted numbers before applying the & operator.
When you are concatenating numeric values, a much better option is to use a Formatted Text Literal, which results in a more readable expression and you can easily control the number format.
Examples
'Hello' & ' ' & 'world' → 'Hello world'
5 & 2 → '52'
['a', 'b'] & 'c' → ['ac', 'bc']
Details
The need to coerce numbers to text using a particular format often arises. Instead of having to rely on setting the number format for the variable that you are defining for this purpose, you can use the NumberToText function.
Enable comment auto-refresher