Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need formula help for a derived column that deals with multiple values

Status
Not open for further replies.

JJArnold

Programmer
Jan 23, 2012
2
US
Hello,

I'm pretty new to Crystal Reports and have run into an issue regarding a particular column in a report. This particular column could potentially have multiple values for any particular account.

For example, Account #1 could have the values X, Y and Z. Account #2 could just have value X and Account #3 may have X and Z etc..

The requirement is for the formula to look at all of the values that are returned for a particular account and display text accordingly. So, for example, if any account has the value of X for this particular column (regardless of whether or not here are other values), then return "YES", if X is not associated with a particular account, "NO" should be returned.

The problem I'm having is that it can't seem to be done using a simple IF/THEN statement because it just looks at the first value that's returned and disregards the rest. So if a particular account has the values X and Y associated with it, it may return Y first and a "NO" will be displayed even though the X value is still associated with it.

Is there an easy way to achieve this functionality? It sounds slightly confusing so I can explain in more detail if necessary.

Here's a simpler, summarized example of what I'm looking for and the issues I'm running into:

A given account could potentially have multiple programs associated with it. I need a formula that will look at all programs associated with a particular account and determine if a certain program is in that list. If that particular program is associated with the account, display "YES", if it is not, display "NO". Since there can be multiple programs associated with any given account, the issue I have is that in those cases, the formula is only looking at the first value returned and disregards the rest...which potentially causes the wrong "YES"/"NO" to be displayed.
 
The formula for Yes/No for Column with an "X" value could work like this...

Local StringVar Array ValList := Split ({table.field},",")
if "X"=ValList then "Yes" else "No"

The = operator should return a "True" if any of the multi values have an "X" in them.

Similar formulas for "Y" and "Z" columns.

Bruce Ferguson
 
Create a formula {@hasX} like this:

if {table.program} = "X" then 1

Create a second formula like this and place it in the group header or footer:

if sum({@hasX},{table.account})<>0 then
"Yes" else
"No"

This assumes you have a group on {table.account} and that the program field cannot be null.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top