Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Technical Questions
Message Icon Topic: Convert IF THEN ELSE to CASE statement Post Reply Post New Topic
Author Message
Hegdej
Newbie
Newbie


Joined: 06 Jun 2018
Online Status: Offline
Posts: 2
Quote Hegdej Replybullet Topic: Convert IF THEN ELSE to CASE statement
    Posted: 11 Jun 2018 at 10:19am
I have the below if then else statement and need help converting to a CASE statement.

if(isnull({@cond1})=false) then 'Cond1'
else if(isnull({@cond2})=false) then 'Cond2'
else if({Command.Age}<3) then 'Under 3'
else if({Command.Age}>17) then 'Above 18'
else 'Between 3 to 17'

This categorizes each element only to one column and that is incorrect. Need the element to be counted in multiple columns. Eg. in 'Cond1' column and one of the age columns or 'Cond1' and 'Cond2' and one of the age columns.

Thanks in advance!
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 12 Jun 2018 at 4:11am
I am assuming that you are using MS-SQL.

case when {@cond1} is not null then 'Cond1'
        when {@cond2} is not null then 'Cond2'
        when {Command.Age} < 3 then 'Under 3'
        when {Command.Age} > 17 then 'Above 18'
        else 'Between 3 to 17' end
IP IP Logged
Hegdej
Newbie
Newbie


Joined: 06 Jun 2018
Online Status: Offline
Posts: 2
Quote Hegdej Replybullet Posted: 12 Jun 2018 at 4:36pm
Thank you!
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.031 seconds.