cancel
Showing results for 
Search instead for 
Did you mean: 

Calculated Column

Former Member
0 Kudos

Hi All,

I want to define calculated column for Text attribute.

Say I have Key column "CID"  having the values A,B,C. If "CID" is A then Text column should is Apple and IF "B" then BALL.

I have writtem like CASE ("CID", 'A','APPLE','B','BALL','C','CAT').

ITS GIVING INVALID EXPRESSION.

can someone help me plz

Accepted Solutions (1)

Accepted Solutions (1)

RashmiAcharya
Advisor
Advisor
0 Kudos

Hi Vasu,

The syntax for case statement is

case(column, cmp1,val1, cmp2,val2, ... , default)

I think as you have not given any default value at the end, validation is failing.

Try below expression,

case("CID",'A','APPLE','B','BALL','C','CAT','null')

Regards,

Rashmi

Former Member
0 Kudos

Thank you Rashmi.

Answers (2)

Answers (2)

Loed
Active Contributor
0 Kudos

Hi,

Try to remove the spaces..Try this code:

CASE("CID",'A','APPLE','B','BALL','C','CAT').

Regards,

Loed

Former Member
0 Kudos

Hi Vasu,

What is the datatype for CID, IS it string if not then change to string and I assume it should help you.

Cheers

Sharma

Former Member
0 Kudos

Hi Sharma,

CID data type is NVARCHAR  and Ztext feild also Nvarchar.  Still Its giving the Issue.

If possible can you give me syntax plz

Thank you

Vasu

Former Member
0 Kudos

Hi Vasu,

I am basis guy so don't have the syntax, but can you check with below link from help.sap.com

http://help.sap.com/saphelp_hanaplatform/helpdata/en/f5/749abef557488d9a747082e5e390d9/content.htm

http://scn.sap.com/thread/3407399

I assume this can help you.   http://scn.sap.com/community/services/blog/2014/03/26/hana-modeling-good-practices -  Forum for syntax Let me know if this helps.

cheers

Sharma

Message was edited by: Deepanshu Sharma

Former Member
0 Kudos

Hi Vasu,

Try the below one.

if("CID"='A','APPLE',if("CID" ='B','BALL',if("CID" = 'C','CAT,null')))