I have folowing data set in my calculation view:
And Im trying create two additional calculated columns for the key ''SAPClient Warehouse TU_NUM":
Column should return ''X", if ((TXT04='CHKO') and (STATUS_VALUE='X')) AND ((TXT04='CHKI') and (STATUS_VALUE='X'))
Column should return "X", if ((TXT04='CHKO') and (STATUS_VALUE=' ')) AND ((TXT04='CHKI') and (STATUS_VALUE='X'))
When I try to create the first column I'm using following code:
if("TXT04"='CHKO',if("STATUS_VALUE"='X', 'X',' '),' ') and if("TXT04"='CHKI',if("STATUS_VALUE"='X', 'X',' '),' ')
But get following syntax error:
Could you give me any tipps about how I can solve my problem in a better way?
Would apreciate any help.
Thanks and BR.
Function IF returns a string value in your expression so there's no AND operator defined on strings (more precisely AND is a function, as you can see via trace).
But I think there's a typo in your code since (A and B) and (C and D)
equals to A and B and C and D
, and you try to "AND" TXT04='CHKO'
and TXT04='CHKI'
which obviously is FALSE
.
If you have only two values, then you can use a single IF if(<1'st group of conditions>, 'X', '')
and group all your conditions accordingly. If you have third value (except 'X' and ''), then replace '' in the snippet with the second if. For more than two output values I prefer case
statement.