Skip to Content

SAP HANA Calculated column if statement

Hi Expert,

I am creating a calculated column in SAP HANA using an if statement but i am encountering some challenges.

The idea of the if statement is that i have three columns; trsfrsum,cashsum and checksum.

If the checksum !=0 then it should display the checksum amount, if the trsfrsum !=0 then display transfer amount and if cashsum !=0 then display cashsum. Which will all be saved in a calculated column called "Amount".

i did this but it is not working as expected. Any solution to this will be appreciated.

Attached is the image of what i wrote.

Regards

Justice

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Dec 14, 2016 at 04:47 PM

    You need several if function calls for that. With one it is not possible in the way you trying it. Also consider that the isNull function is not the same than "!=0" as described by you.

    The following expression fits your text description:

    if("CheckSum" != 0,"CheckSum", if("TrsfrSum" != 0,"TrsfrSum", if("CashSum" != 0,"CashSum",0)))

    Regards,
    Florian

    Add comment
    10|10000 characters needed characters exceeded

    • Florian ,

      i did this for the numeric to nvarchar but i believe i missed something.

      if(cast("CheckSum" as Nvarchar) != 0,cast("CheckSum" as Nvarchar), if(cast("TrsfrSum" as Nvarchar) != 0,cast("TrsfrSum" as Nvarchar), if(cast("CashSum" as Nvarchar) != 0,cast("CashSum" as Nvarchar),0)))