on 12-14-2016 4:34 PM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
So "varchar" should give you the hint, why the coding fails. Comparing a varchar value against a number value produces the error message.
In case your "varchar" columns contains only number values you could cast the varchar values to e.g. doubles like following:
if(double("CheckSum") != 0,double("CheckSum"), if(double("TrsfrSum") != 0,double("TrsfrSum"), if(double("CashSum") != 0,double("CashSum"),0)))
But from my point of view you have already a not clean design of your data model when you store number values (which are indicated by the column names e.g. "..sum..") in varchar columns.
I understand you, but the aim of my calculated column with reference to Acct is to be able to join my calculated column that will hold GL account codes of different payment means to the GL Account view that has the Acct code and AcctName.
So I am trying to display transfer account code when the transfer amount is not Zero and some for the other accounts.
That's the aim of my calculated column
User | Count |
---|---|
95 | |
11 | |
11 | |
6 | |
6 | |
4 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.