Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Technical Questions
Message Icon Topic: Formula with Select Statement Post Reply Post New Topic
Page  of 2 Next >>
Author Message
kurt
Newbie
Newbie


Joined: 08 Sep 2014
Online Status: Offline
Posts: 22
Quote kurt Replybullet Topic: Formula with Select Statement
    Posted: 01 Jun 2015 at 6:24am
I have a datasource defined by sql command. It produces a table with 4 fields, ID, Category, Item, Checked.

In my report, the id is matched to a record using select expert. In my report I want to display "checked" which is 0 or 1 based on category and item. so I am needing a formula. I want to return chr(168) or chr(252) based on true/false. Here is what I started with, obviously broke.

Select {Command.Checked}
where {Command.category}="Hazards" and {Command.item}="Electric Shock"
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 01 Jun 2015 at 7:21am
not following your process here but for display purposes you can create a formula field from your true/false field as
if table.field then chr(252) else chr(168)
then use the wingdings font for that field
IP IP Logged
kurt
Newbie
Newbie


Joined: 08 Sep 2014
Online Status: Offline
Posts: 22
Quote kurt Replybullet Posted: 01 Jun 2015 at 7:40am
That helps, but I need to also specify which record to use. Each record will match like 10 categories in the view. I need to select the category which matches "xxx".

if
(
If table.category matches "xxx"
then select table.field
)
then chr(252)
else chr(168)
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 01 Jun 2015 at 7:59am

this appears that you are attempting to replace a join with a formula...?

what is your raw data like?
IP IP Logged
kurt
Newbie
Newbie


Joined: 08 Sep 2014
Online Status: Offline
Posts: 22
Quote kurt Replybullet Posted: 01 Jun 2015 at 8:10am
Here is a screen cast which shows the data in SQL and then the crystal reports formula editor. Hopefully makes sense. http://screencast.com/t/Nu5tzRvPAYM5
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 01 Jun 2015 at 8:32am
a formula field is an evaluation for that row of data from the dataset that you have altready defined via the Command object (or other data source) and any select critera (in the select expert).
 
Your
"if criteria then select ..."
does not really make any sense as it is only evaluating for that one row of data which already includes all fields in that row.
Are you trying to get a group level result? Like only a single check box displayed for for all of the one grouping of permitid = 2 ?
 
 
IP IP Logged
kurt
Newbie
Newbie


Joined: 08 Sep 2014
Online Status: Offline
Posts: 22
Quote kurt Replybullet Posted: 01 Jun 2015 at 8:48am
permitID = 2 does not produce a unique row in the command dataset. it will produce many matching rows. It is a one to many relationship in the database. The permit has core data (id, date, type, etc) and then the permit has these categories of hazards (electric shock, fire, flooding, etc). In the application the user selects a check box which marks the appropriate hazards. so on the crystal report I want to show a checkbox next to Electric Shock, Fire, etc. The way we have done it in past is to write a subreport for each checkbox on the report. And the subreport will have select expert to identify the exact row of data that applies. This could mean as many as 100 subreports on one crystal report. I was hoping to avoid that. Thanks for your help, I am guessing this is too confusing to handle here.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 01 Jun 2015 at 9:06am
I think you are way over complicating this.
You are trying to show if a field is checked or not, correct?
You may have to adjust a bit
Group on the permit ID to get keep each permit togther.
group on the Category field.
THis will keep all of the categorie fields for that ticket together
drag and drop the checked field onto the detail section
drag and drop the item field onto the detail section just to the right of the checked field
right click on the checked field
select format field
select common tab
select display string formual field
use
if currentfieldvalue then chr(252) else chr(168)
select Font tab
under font select WingDing
Preview
 
IP IP Logged
kurt
Newbie
Newbie


Joined: 08 Sep 2014
Online Status: Offline
Posts: 22
Quote kurt Replybullet Posted: 01 Jun 2015 at 9:51am
I understand where you are going. We have customer requirements that are very specific as to the data formatting on the page. So we insert the check boxes one by one. This is why I was trying to do a record select in a formula. As it is, I have to write a subreport that returns a wingding that I display on the form. this equals like 37 subreports on the one report I am currently working.

Again, thanks for being willing to discuss.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 01 Jun 2015 at 10:14am
The direction you were going will not work in Crystal.
I would either change your COMMAND object to use  PIVOT and convert your rows into columns (per permitid). You can then drag and drop the fields into placement on a group header footer or detail
 
or
 
You can do what you are trying to do as a group footer data as a ton of running totals using conditional evaluation formulas.
example.
create a new running total
name = HazardElectricShock
Field to summarize= checked
type= maximum
evaluate = use a formula
{Command.category}="Hazards" and {Command.item}="Electric Shock"
reset = on change of group 
place this in the permitid group footer (RTs do not work in headers)
apply the same check box formatting to this RT.
you can now move it around the footer wherever you want. You can add a texct field as the label next it.
you can create one RT per check box and have easy placement on the canvas in the same group footer.
 
IP IP Logged
Page  of 2 Next >>
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.016 seconds.