Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

concatenate

Hi

I am concatenating 2 fields using an expression in an multiselect list box , the fields might be having some nulls , how do i avoid the nulls , the expression does not appear in presentation tab to select avoid null option , how do i avoid null for an expression?

Here is my expression:

=(field1 &'-'& field2)

Thanks

1 Solution

Accepted Solutions
Not applicable
Author

You can try this.


=If(Not IsNull(field1) and Not IsNull(field2),field1&' - '& field2)


View solution in original post

7 Replies
maneshkhottcpl
Partner - Creator III

Hi,

U can use expression to conver null like if(isnull(field1,'-',field1) & '-' & if(isnull(field2,'-',field2)

this is the solution as per my understanding ,please le me know it is right or not. Expalin ur ssue in more details.

Anonymous
Not applicable
Author

I get an error with the above expression may be ) is missing i tried adding that , still did not work , i requirement is pretty simple, i just want to concatenate 2 fields with ''-" a hyphen in the middle and avaoid null in both the feilds.

Thank you..

Miguel_Angel_Baeyens

It's not clear whether you are doing that in the script. If this is the case, then something like the following should work:

Table:LOAD If(Len(Field1) > 0, Field1, 'Null') & '-' & If(Len(Field2) > 0, Field2, 'Null') AS CompositeFieldFROM data.source


Instead of the "Null" set any value should a field is empty so you can easily check it later.

This will work as expression, although it will affect severely in the document performance.

Hope that helps.

Anonymous
Not applicable
Author

No way to have this as a expression?

Anonymous
Not applicable
Author

I get value Null-Null in my list box if i use above as an expression

Not applicable
Author

You can try this.


=If(Not IsNull(field1) and Not IsNull(field2),field1&' - '& field2)


Miguel_Angel_Baeyens

Attached is the sample application. Works fine with both script and expression. By default (when nothing is selected) "Null-Null" is displayed, since the expression is made of different fields.

I always use Len() > 0 rather than IsNull() since the "null" values depend on the database, driver, computer... Len() always returns proper results.

Regards.