javasqlexpressionbirtexpressionbuilder

How to replace a column result if null with another column result in BIRT


I would really appreciate some help with a computed column using an expression in Birt.

I have two columns which are giving results, one gives email addresses and one gives contact numbers: telephone, mobile..

When the email result is null then the contact number column shows a number, these are separate communication methods from a table in sql.

What I would like to do is create a new computed column for both the email address and the telephone number, when emailaddress is null then replace with contactnumber = contact and when contactnumber is null replace with emailaddress.

I've looked at a few similar questions online and found that entering the below script into the birt expression builder is accepted when you click validate, but it is not loading the report in the erp software I am using.

Is the expression itself correct?

if(row["destination"] == null){
row["contact"];
}
else if(row["contactnumber"] == null){
row["contact"];
}
else{
return true;
}

Kind regards,

Stuart


Solution

  • By using the following in a Birt Expression, this replaces one column with another columns value if null.

    if(row["destination"] == null){
    row["contactnumber"];
    } 
    else { 
    row["destination"]; }