March 28, 2012, 04:56 PM
AnnaRConcatenate syntax
What is a difference in using | vs || to concatenate two columns?
March 28, 2012, 05:08 PM
AnnaRFound the difference:
|| trims the column while | does not: for instance:
var1 = 'cat '
var2 = 'dog'
var1 | var2 => 'cat dog'
var1 || var2 => 'catdog'
Please let me know if there are other differences.
March 28, 2012, 05:13 PM
WazA single | is a soft concatenate, a || is a hard concatenate.
e.g.
Text1 = 'text '
Text2 = ' more '
Text3 = Text1 | Text2
Text3 will contain 'text more '
Text4 = Text1 || Text2
Text4 will contain 'text more '
With a hard concatenate, the trailing spaces are shifted to the end of the expression. If you start using parentheses, you can control where the hard and soft concats happen.
e.g.
Text1 = 'text '
Text2 = 'more '
Text3 = Text1 || Text2
Text3 will contain 'textmore '
Text4 = Text1 || (' ' | Text2)
Text4 will contain 'text more '