If I have the formula:
Join(" ", [First Name], [Last Name], [RowId])
And [Last Name]
is blank, the result I’ll get back will be something like:
Connor 123
where there’s a small extra space between the name and the id.
It would be better if the Join
function knew to only add the space if the value is non-blank.
Before anyone recommends using the Trim()
formula, this doesn’t work very elegantly. Just go ahead and try to do the trim for this particular instance.
Furthermore, it’s not always sufficient, for example, what if I’m constructing a hierarchy like @Todd_Olson was asking for the other day:
List(1, "B", "", 2).WithName([Levels List],
Join(".", [Levels List])
)
(Let’s imagine here that List(1, "B", "", 2)
is actually the result of some formula).
What I would ideally see is this:
1.B.2.
But instead, I’ll see 1.B..2
. Not really useful.
What if I really want a dot to show up there? I propose that if you pass in the separator as the value to the Join
it causes just that value to show up. I.e.
Join(".", 1, "B", "", 2)
→ 1.B.2.
, and
Join(".", 1, "B", ".", 2)
→ 1.B..2.
(not 1.B...2.
like it would do right now.)
This is safe to do because the only case that you can’t produce with this sort of join would be Join("", [Values])
but of course that’s just a place to use Concatenate([Values])
.
Suddenly this would allow us to do things like:
Join(" ", [First Name], [Last Name], [RowId], [Column], ...)
Without having to think at all about whether one of those is blank.
The current alternative is to write a regex like [Value].RegexReplace("\s{2,}", " ")
but regexes are:
- opaque (I mean, what does
"\s{2,}"
even mean?) - not well known
- error prone
Alternatively, a formula like, RemoveDuplicateSpaces()
could do the trick.