Author |
Message |
aqrnl
Newbie
Joined: 23 Nov 2015
Location: United States
Online Status: Offline
Posts: 6
|
Topic: displaying parameter Posted: 08 Jan 2018 at 6:55am |
I know you can create a formula like the following to list the parameter items chosen.
Join({?Problem Codes},", ")
The problem is that there are a log of codes and if the users chooses all of them there is not enough room to display them. In situations where the user chooses all can Crystal just display "ALL'? If so, how would I do that?
|
IP Logged |
|
kevlray
Admin Group
Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
|
Posted: 08 Jan 2018 at 8:28am |
Basically I normally create a value for the parameter list of values called All, but I am not sure (have not tried it) for a dynamic list.
For the All, I use a value of *, then in the selection formula, I use the 'is like' comparison. Then for display formula, look for the prompt value of 'All'
|
IP Logged |
|
Valert16
Groupie
Joined: 21 Mar 2016
Location: Spain
Online Status: Offline
Posts: 57
|
Posted: 09 Jan 2018 at 12:56am |
If you know the maximum number of values (all), you can use a formula to compare the number of chosen values with this maximum.
Let's say there are 7 values to choose. The formula can be:
If Ubound({?Problem Codes}) = 7 Then
"ALL"
Else
Join({?Problem Codes},", ")
|
IP Logged |
|
aqrnl
Newbie
Joined: 23 Nov 2015
Location: United States
Online Status: Offline
Posts: 6
|
Posted: 09 Jan 2018 at 9:36am |
Valert16: Your idea worked but is awkward in the long run because codes are added over time. Thank you.
Keviray: Your idea looks like it will work in the long run but I was unable to follow it. Please be more specific as to the selection formula. Thank you.
|
IP Logged |
|
kevlray
Admin Group
Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
|
Posted: 10 Jan 2018 at 5:04am |
First off, do you have a list of values for the parameter? If so, are they static or dynamic? If they are dynamic, I will have to do some testing.
|
IP Logged |
|
DBlank
Moderator
Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
|
Posted: 10 Jan 2018 at 8:45am |
MTC - for an 'all' option...
if you add an 'All' selection to the parameter (like from a union statement in a crystal command as a list source) the record selection should be a simple as
(?param= 'All' or ?param = table.field)
The first part meets the condition to not filter but is much more efficient than having to actually meet a LIKE condition.
|
IP Logged |
|
aqrnl
Newbie
Joined: 23 Nov 2015
Location: United States
Online Status: Offline
Posts: 6
|
Posted: 10 Jan 2018 at 8:45am |
Kevlray,
Codes are added over time so values are dynamic. Thank you for your effort.
|
IP Logged |
|
kevlray
Admin Group
Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
|
Posted: 10 Jan 2018 at 10:55am |
The other way, which I just thought of. If you make the parameter optional (I forget what version they made that possible). Then if the user does not enter anything, then nothing is filtered.
|
IP Logged |
|
Valert16
Groupie
Joined: 21 Mar 2016
Location: Spain
Online Status: Offline
Posts: 57
|
Posted: 11 Jan 2018 at 1:26am |
I think the solutions proposed above about adding an 'all' option or using an optional parameter shoud work. I simply add here another possibility, don't know if it'll be helpful.
It's seems clear the parameter must be dynamic because the codes can change. I propose a way to get the total number of codes (a little knowledge of SQL is needed)
Add a new command from database expert. This command must contain a sentence like 'Select Count (Distinct CodeField) as TotalCodes From...' (the syntax may vary with every database). The goal is getting a unique field wich contains the count of distinct codes every time the report is executed. This select statement should be based on the same query that fills the list of codes in the dynamic parameter. Leave this command unlinked from any other table or command you already have.
You may receive some warnings about your link configuration, ignore them.
Now you can detect if all values have been selected, using this formula (Basic syntax):
If Ubound({?Problem Codes}) = {NewCommand.TotalCodes} Then
formula = "ALL"
Else
formula = Join({?Problem Codes},", ")
End If
|
IP Logged |
|
lockwelle
Moderator
Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
|
Posted: 11 Jan 2018 at 12:51pm |
you could also just cut off the list after x characters...or back track to the last comma and replace with an ellipse(...)
|
IP Logged |
|
|