cancel
Showing results for 
Search instead for 
Did you mean: 

Calculated Column Logic

faisalfa
Explorer
0 Kudos

Hi, I've been trying to write a SQL script in HANA Studio for creating a calculated column using the following pseudo code logic

If ("AUGBL_ORIG" is empty) { if ("AUGBL_BSEG_Vendor" is empty) { return "AUGBL_BSEG_CUSTOMER" } else { return "AUGBL_BSEG_Vendor" } } else { return "AUGBL_ORIG" } What would would be the best way to write the logic? Should i use CASE function or IF statements

Please help!

Accepted Solutions (1)

Accepted Solutions (1)

pfefferf
Active Contributor
0 Kudos

IF function would be efficient for that. In case "empty" means null, you an also use the ISNULL function instead of the "!=" operator which compares to '' in the following example:

if("AUGBL_ORIG" != '', "AUGBL_ORIG", if("AUGBL_BSEG_Vendor" != '',"AUGBL_BSEG_Vendor","AUGBL_BSEG_CUSTOMER"))
faisalfa
Explorer
0 Kudos

Hi Florian,

I'm getting an error when I'm trying to save and validate the HANA model. I'm running the script for calculated column in calculation engine.

Do you have an idea as to what is causing the error?

I have propagated the calculated column to semantics & have checked and activated the dependent HANA model.

Regards

Faheem

pfefferf
Active Contributor
0 Kudos

According to the error message in your node on which you apply the expression, the attribute/column "AUGDT_ORIG" is missing. I would check for that 🙂

faisalfa
Explorer
0 Kudos

I checked for the missing column & added it to the output.

The issue is resolved.

Thank you for your inputs and prompt replies.

Answers (0)