Difference between revisions of "Text Concatenation Operator: &"
Line 2: | Line 2: | ||
[[Category:Doc Status C]] <!-- For Lumina use, do not change --> | [[Category:Doc Status C]] <!-- For Lumina use, do not change --> | ||
− | + | == A & B== | |
− | + | Evaluates «A» and «B», coerces their element values to text, and concatenates the result. | |
− | + | 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. | |
− | + | == Examples == | |
− | + | :<code>'Hello' & ' ' & 'world' → 'Hello world'</code> | |
− | = Examples = | + | :<code>5 & 2 → '52'</code> |
− | + | :<code>['a', 'b'] & 'c' → ['ac', 'bc']</code> | |
− | :'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, a common technique is to create a [[User-Defined Function]] to perform the particular coercion of interest. Then in your definition, you just call that 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, a common technique is to create a [[User-Defined Function]] to perform the particular coercion of interest. Then in your definition, you just call that function. | ||
For example, create the User-defined function: | For example, create the User-defined function: | ||
+ | :<code>Function ToCurrencyText(x) := "" & x</code> | ||
− | + | Then while viewing the object window for <code>ToCurrencyText</code>, select '''Number Format...''' ''(Ctrl+B)'' and set to ''Fixed Point'', ''Showing Currency'', two digits, and thousand separators. | |
− | |||
− | Then while viewing the object window for ToCurrencyText, select '''Number Format...''' ''(Ctrl+B)'' and set to Fixed Point, Showing Currency, two digits, and thousand separators. | ||
With that function defined, elsewhere you can use the function to convert numeric values to currency text: | With that function defined, elsewhere you can use the function to convert numeric values to currency text: | ||
− | + | :<code>ToCurrencyText(Revenue)</code> | |
= See Also = | = See Also = | ||
− | |||
* [[JoinText]] | * [[JoinText]] | ||
+ | * [[Concat]] | ||
+ | * [[ConcatRows]] | ||
+ | * [[ConcatN]] | ||
+ | * [[Set_Functions#Function_SetUnion|SetUnion]] | ||
+ | * [[Aggregate]] | ||
+ | * [[NumberToText]] |
Revision as of 01:20, 29 January 2016
A & B
Evaluates «A» and «B», coerces their element values to text, and concatenates the result.
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.
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, a common technique is to create a User-Defined Function to perform the particular coercion of interest. Then in your definition, you just call that function.
For example, create the User-defined function:
Function ToCurrencyText(x) := "" & x
Then while viewing the object window for ToCurrencyText
, select Number Format... (Ctrl+B) and set to Fixed Point, Showing Currency, two digits, and thousand separators.
With that function defined, elsewhere you can use the function to convert numeric values to currency text:
ToCurrencyText(Revenue)
Enable comment auto-refresher