Print Page | Close Window

Record Selection Using Parameters

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=22592
Printed Date: 01 May 2024 at 1:19pm


Topic: Record Selection Using Parameters
Posted By: TheITGuyAtWork
Subject: Record Selection Using Parameters
Date Posted: 07 May 2018 at 9:20am
Hi,

I am not sure if I am doing this the correct way or if there is a different approach to this. I have created a report which summarizes inventory by item category.  Instead of having multiple similar reports, I would like to parameterize it so the user can select which report they would like to view.  The report works well if I use the select expert and filter the category using the “Is Like” statement, as I have a number of groups and the statement W?? selects all of the groups that I need.  I am also able to add multiple categories using the same “Is Like” statement.  My issue is that I am having a slight problem translating this to parameters. 
I have created a parameter called ReportSelection and fed it to the select expert using the “Is Like” statement.  I am unable to add multiple items to the same parameter item line.  I have added descriptions to the parameter choices and hidden the selections to the users.  The only lines that seem to work are lines with single items. 
 
I have arranged it as follows:
Value                                    Description
*                                          All Items
CIG, CIGS                             Cigars and Cigarettes
COF, MHS                              Coffee and Misc Hotel Supplies
JC                                         Juice
LIQ, LI3                                Local Liquor and Liquers
W??                                      Wines
 
The only ones that work are All Items, Juice and Wines.  I have tried using single and double quotes to no avail.
 
Is there any way to accomplish this task or am I looking at this the wrong way?
Cheers and thanks in advance.




Replies:
Posted By: kevlray
Date Posted: 08 May 2018 at 7:32am
That is true.  You cannot have multiple items in the Value column (unless you expect someone to enter  CIG, CIGS.  I have not tried this, but can you add each item separate with the same description.

CIG     Cigars and Cigarettes
CIGS   Cigars and Cigarettes


Posted By: DBlank
Date Posted: 08 May 2018 at 8:18am
another idea would be to create another field to convert your combinations into a single 'code'.
//SelectValue
if table.field = 'CIG' then 'CIGS' else
if table.field = 'COF' Then 'MHS' else
if table.field = 'LIQ' Then 'LI3'
else table.field

Use a static parameter that you set your values as you want

All Items as 'ALL'
Cigars and Cigarettes as 'CIGS'
Coffee and Misc Hotel Supplies as MHS
Juice as JC
Local Liquor and Liquers as LI3
Wines as W??

In your select Expert
({?Param} = 'ALL' OR {?Param} IN {@SelectValue})


Posted By: TheITGuyAtWork
Date Posted: 08 May 2018 at 8:43am
Hi Kevlray,

Thanks for the response.  I tried your suggestion and the report displays 2 lines with the same parameter when it is called.  Each separate line showing their respective data instead of a combination of both.


Posted By: TheITGuyAtWork
Date Posted: 08 May 2018 at 8:52am
Hi Dblank.

I am trying to wrap my head around what you wrote.  The thing is that I want both CIG and CIGS passed in the search.  As well as COF and MHS, and LIQ and LI3 respectively.

If I don't use parameters and I use the select expert, the formula shows up as:

{ICITEM.CATEGORY} like ["CIG", "CIGS"]

There are a number of Categories such as WAG, WCH, WCH, WIT, which were successfully summarized with W??.

I am still trying to digest what you sent.

Cheers.


Posted By: DBlank
Date Posted: 08 May 2018 at 9:30am
Ahh.. wasn't sure what W?? is.
Basically I am suggesting you 'convert' your raw data to the categories that you want them to be via a simple formula field that I called "SelectValue". This allows you to stick two or more distinct items into a 'grouping' of your choice

//SelectValue
if ICITEM.CATEGORY = 'CIG' then 'CIGS' else
if ICITEM.CATEGORY = 'COF' Then 'MHS' else
if ICITEM.CATEGORY = 'LIQ' Then 'LI3'
if ICITEM.CATEGORY like 'W??' then 'WINE'
else ICITEM.CATEGORY

Now that you created a formula field that converts all of your different types into the groupings you want, use the @SelectValue as your selection option, not the original ICITEM.CATEGORY field.
To make it easier for the user selecting options, you can create a static parameter with descriptions of the 'grouped items' and the value per @SelectValue results.



Print Page | Close Window