Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Concatenation of multiple columns
DMUK
Hi all,<br />
<br />
Trying to concatenate some values to make an address. Using computed column expression like this. Seems to be an invalid expression. The goal is to check if columns are empty and create a comma separated address based on the results.<br />
<br />
Can anyone help?<br />
<br />
Thanks!<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
var line1 = row["LINE1"]; var line2 = row["LINE2"]; var line3 = row["LINE3"]; var city = row["CITY"]; var state = row["STATE"]; var province = row["PROVINCE"]; var zip = row["ZIP"];
if(line1 != ""){row["LINE1"]+", ";} if(line2 != ""){row["LINE2"]+", "} if(line3 != ""){row["LINE3"]+", "} if(city != ""){row["CITY"]+", "} if(state != ""){row["STATE"]+", "} if(province != ""){row["PROVINCE"]+", "} if(zip != ""){row["ZIP"]}
</pre>
Find more posts tagged with
Comments
mwilliams
Hi DMUK,<br />
<br />
Try the following as your computed column expression:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
temp = "";
if (row["LINE1"] != null){
temp = row["LINE1"] + ", ";
}
if (row["LINE2"] != null){
temp = temp + row["LINE2"] + ", ";
}
if (row["LINE3"] != null){
temp = temp + row["LINE3"] + ", ";
}
if (row["CITY"] != null){
temp = temp + row["CITY"] + ", ";
}
if (row["STATE"] != null){
temp = temp + row["STATE"] + ", ";
}
if (row["PROVINCE"] != null){
temp = temp + row["PROVINCE"] + ", ";
}
if (row["ZIP"] != null){
temp = temp + row["ZIP"];
}
temp;
</pre>
<br />
Let me know.
DMUK
<blockquote class='ipsBlockquote' data-author="mwilliams"><p>
Let me know.</p></blockquote>
<br />
Works perfectly - thanks - I have a feeling that will come in useful more than once.
mwilliams
Glad to be of help. Let us know whenever you have questions!