Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
Solved

# Help with my crystal report - trying to use a select case

Posted on 2007-12-06
Medium Priority
5,333 Views
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.

``````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
``````
0
Question by:yzlbrmn
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points

LVL 28

Expert Comment

ID: 20420471
Can you post the actual formula you are trying to use and not pseudo code?
Your code always returns the same total fields regardless of the category value.  Is this what you want?
0

Author Comment

ID: 20420577
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.cat} = 1) then
{SP_Package_Coverage;1.total}
else if ({SP_Package_Coverage;1.cat} = 2) then
{SP_Package_Coverage;1.total}
else if ({SP_Package_Coverage;1.cat} = 3) then
{SP_Package_Coverage;1.total}

0

LVL 28

Accepted Solution

bdreed35 earned 2000 total points
ID: 20420720
Does this work?

select {SP_Package_Coverage;1.cat}
case 1 :{SP_Package_Coverage;1.total1}
case 2 :{SP_Package_Coverage;1.total2}
case 3 :{SP_Package_Coverage;1.total3}
case 4 :{SP_Package_Coverage;1.total4}
case 5 :{SP_Package_Coverage;1.total5}
0

LVL 3

Expert Comment

ID: 20420798
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}
``````
0

LVL 3

Expert Comment

ID: 20420815
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.
0

LVL 1

Expert Comment

ID: 20592617
Forced accept.

Computer101
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
###### Suggested Courses
Course of the Month9 days, 23 hours left to enroll