Skip to Content
0

Calculated Column Logic

Feb 16, 2017 at 11:39 AM

141

avatar image

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!

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
Florian Pfeffer
Feb 16, 2017 at 11:56 AM
0

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"))
Show 3 Share
10 |10000 characters needed characters left characters exceeded

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

capture.jpg (113.1 kB)
0

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 :-)

0

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

The issue is resolved.

Thank you for your inputs and prompt replies.

0