yzlbrmn
asked on
Help with my crystal report - trying to use a select case
Hi, I am new to crystal reports, so please help.
I am trying to create a formula in crystal that will use 2 recordset fields (category and total), and based on the category will return a corresponding total.
There are 5 categories available.
I tried using if statement, as well as select case, but it only returns the value of the first one.
Please help.
I am trying to create a formula in crystal that will use 2 recordset fields (category and total), and based on the category will return a corresponding total.
There are 5 categories available.
I tried using if statement, as well as select case, but it only returns the value of the first one.
Please help.
dim amount as number
if category=1 then
amount =total
elseif category=2 then
amount =total
ElseIf category=3 Then
amount =total
ElseIf category=4 Then
amount =total
ElseIf category=5 Then
amount =total
End If
formula =amount
ASKER
Thanks for replying - here is what I am trying to do - based on the category, i want to display an actual total. My recordset returns me 2 fields -category and total, so it looks like this:
Category1, Total1
Category2, Total2
Category3, Total3
Category4, Total4
Category5, Total5
I need to know the total for corresponding category, but insteas it only gives me the category1.
My formula looks like this:
if ({SP_Package_Coverage;1.ca t} = 1) then
{SP_Package_Coverage;1.tot al}
else if ({SP_Package_Coverage;1.ca t} = 2) then
{SP_Package_Coverage;1.tot al}
else if ({SP_Package_Coverage;1.ca t} = 3) then
{SP_Package_Coverage;1.tot al}
Category1, Total1
Category2, Total2
Category3, Total3
Category4, Total4
Category5, Total5
I need to know the total for corresponding category, but insteas it only gives me the category1.
My formula looks like this:
if ({SP_Package_Coverage;1.ca
{SP_Package_Coverage;1.tot
else if ({SP_Package_Coverage;1.ca
{SP_Package_Coverage;1.tot
else if ({SP_Package_Coverage;1.ca
{SP_Package_Coverage;1.tot
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I think you are doing it a hard way...try this;
SELECT category
CASE 1 : {first total}
CASE 2 : {second total}
CASE N : {Nth total}
DEFAULT : {default total}
bdreed35 beat me to finishing my response, what he has is correct and the only thing i would add is that if you want a default to handle cases that do not fit into the expected values for category then follow the form I posted above.
Forced accept.
Computer101
EE Admin
Computer101
EE Admin
Your code always returns the same total fields regardless of the category value. Is this what you want?