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 MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

varying selection expert on Multiple Groups

Status
Not open for further replies.

cashewsky

Technical User
Aug 22, 2006
5
US
Hello all!

I have a question concerning the selection and layout of data in a crystal report that I am renovating. Right now it accepts input from the user:

BegDate
EndDate

These parameters are used in the Select Expert to list summary data in Group 1. There is also a chart that is built from this data (a percentage field). What I wish to do is ask for more info from the user:

LastYearBegDate
LastYearEndDate

I want to create another group so that I can create a side-by-side chart with LastYear's data and this year's data.

Both Groups would be pulling the same data fields from the database, I just want Group2 to be selected differently based on the added LastYear fields.

Thanks,
Cashewski
 
You need to get beyond the Select Expert, use Report > Selection Formulas > Records. Make a selection like
Code:
{your.date} in [BegDate to EndDate]
or {your.date} in [LastYearBegDate to LastYearEndDate]

For grouping, use a formula like
Code:
if {your.date} in [BegDate to EndDate]
then "a) This Year"
else "b) Last Year"

You should be able to group on this. (It may vary for versions of Crystal and it is best to say which you are using.)

[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
Please at least post your software version.

I wouldn't ask the user for the last year info in different parameters, Crystal can do that for you for the same periods last year, you're only asking for trouble assuming that they'd always enter both periods correctly.

Select Report->Selection formula->Record

Change the record selection to something like:

(
{your.date} in {?BegDate} to {?EndDate}
or
{your.date} in dateadd("yyyy",-1,{?BegDate}) to dateadd("yyyy",-1,{?EndDate})
)

Now the proper data is returned.

Now create a formula such as:

totext(month{table.date},"00") & "-" & totext(year{table.date},0."")

And use this formula to group the data in the chart.

This assumes that by "I want to create another group so that I can create a side-by-side chart with LastYear's data and this year's data. " you meant that you wanted each month of each years data represented, not just the years.

The reason why I think year is meaningless here is that the users could enter a date range that spans a year, so if you're comparing a years data, part of the years data would fall into each group, and you would have 3 years.

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top