Hi all,
I have a dataset with different columns that have some empty random cells (like the example in the table below). I would like to concatenate the values of the different columns and use the "_" to separate the content of the cells only if the content of the cells is different from empty value (as in column "concat" below). Does anyone have a suggestion on a how to to this operation in a smart way?
Thanks for your help!
| Name | Age | Sex | Concat |
Mads | 31 | | Mads_31 |
| | | M | M |
| John | 25 | | John_25 |
| Julia | 19 | F | Julia_19_F |
Hi, here is yet another formula.
</CODE></P>
<PRE><CODE class=" language-jsl">Concat Items( Words( :Name || "," || :Age || "," || <SPAN class="lia-emoticons-autosuggestions"><SPAN class="lia-emoticons-search-term">:Sex</SPAN></SPAN>, "," ), "_" )
</CODE></P>
<P>Cheers,</P>
<P>Brady</P></LINGO-BODY><LINGO-SUB id="lingo-sub-389902" slang="en-US" mode="NONE">Re: Concatenate columns with empty cells</LINGO-SUB><LINGO-BODY id="lingo-body-389902" slang="en-US" mode="NONE"><P>Here is one way of writing the formula</P>
<PRE><CODE class=" language-jsl">colList = {"Column 1", "Column 2", "Column 3"};
x = "";
For( i = 1, i <= N Items( colList ), i++,
If( As Column( colList[i] ) != "",
If( x != "", x = x || "_" );
x = x || Char( As Column( colList[i] ) );
)
);
Trim( x );
You should be able to use a simple function in a new column Concat:
