Hello - Can anyone help me with a case statement?...
# suiteanalytics
l
Hello - Can anyone help me with a case statement? I have the following case statement which works fine but to the last part I would like to add - when {postingperiod} is 'Jan 2023', 'Feb 2023' then {amount} *.23 or when {postingperiod} is 'May 2023', 'Apr 2023', 'Jul 2023' then {amount} *.21 etc for the whole year. I have tried several different wording but most of the time get invalid field or an error . TIA CASE WHEN (({account} = ('60000 Wages') or {account} = ('60500 Commission Regular') or {account} = ('60501 Commission ERC')) and {subsidiarynohierarchy} = 'ABC') then {amount} * .18 WHEN (({account} = ('60000 Wages') or {account} = ('60500 Commission Regular') or {account} = ('60501 Commission ERC')) and {subsidiarynohierarchy} = ‘XYZ’) Then {amount} * .13 WHEN (({account} = ('60000 Wages') or {account} = ('60500 Commission Regular') or {account} = ('60501 Commission ERC'))) Then {amount} * .23 END
e
Try this
CASE WHEN {account} IN ('60000 Wages','60500 Commission Regular','60501 Commission ERC') AND {subsidiarynohierarchy} = 'ABC' THEN {amount} * .18 WHEN {account} IN ('60000 Wages','60500 Commission Regular','60501 Commission ERC') AND {postingperiod} IN ('Jan 2023', 'Feb 2023') AND {subsidiarynohierarchy} = 'XYZ' THEN {amount} * .13 WHEN {account} IN ('60000 Wages','60500 Commission Regular','60501 Commission ERC') AND {postingperiod} IN ('Jan 2023', 'Feb 2023') THEN {amount} * .23 WHEN {account} IN ('60000 Wages','60500 Commission Regular','60501 Commission ERC') AND {postingperiod} IN ('May 2023', 'Apr 2023', 'Jul 2023') THEN {amount} * .21 END
l
@Eric B Your are Brilliant ! Thank you so much it worked perfectly !
d
Could potentially be tidied up, if I've understood how you're wanting to structure it (subsid ABC is 0.18, subsid XYZ is 0.13, any other subsid is based on the posting period)
l
@David B Yes, that is correct. I will give that a try. I was trying to make it more compact but I kept getting errors. Thank you !
👍 1