Power Apps – Concatenate but skip empty

I have a text control in Power Apps that I need to be the concatenate of a number of variables with a dot in between. It’s pretty straight forward and in theory all I need do is something like cvVar1 & "." & cvVar2 & "." cvVar3 where cvVar1-3 are my context variables.

Thing is, sometimes the variables are empty. So if cvVar1 is “a” and cvVar2 is empty and cvVar3 is “b” the above code results in “a..b” – which is not what I want. I want it to be “a.b”.

So I want the code to be smarter and skip such variables and not add the dot before or after depending on whether the other variables around it are empty or not. Here’s what I did.

At the stage where I want to concatenate, I first put them all into a table.

Then I concatenate, but skip empty ones.

This goes through the elements in the table, filters to the ones whose length isn’t 0, takes these, and concatenates them. This bit is where the filtering happens: Filter(gblFinalName, Len(Value)<>0).