Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Help with formulas Post Reply Post New Topic
Author Message
wisdom
Newbie
Newbie


Joined: 08 May 2010
Online Status: Offline
Posts: 6
Quote wisdom Replybullet Topic: Help with formulas
     Posted: 08 May 2010 at 10:18am

Is there a solution to this problem?

 
In my work database contains probably hundreds of tables but to make it easier to understand, suppose there are just 2 tables for now and the CONTACT table below stores multiple records of an individual's job title.  In real life, a person can work at more than one organisation.  The problem is when I try to include the jobtitle field, it will pull all their record.  This is indicated and controlled on their Main Contact / Organisation field.
 

A solution to this is to ensure the Main Contact or Main Organisation field is selected with a Y or N.  This pulls out only one job title of the individual, and so on report view, you will not see duplicate(or more) of the  Individual record.

 
However, by doing this through Crystal Report without using any formulas to control the output, a "single individual" who does not belong to any organisation, somehow, will not get selected.  Therefore, I will not see this single individual on report view.  To resolve this, I remove both the Main Contact/Organisation in the selection criteria.
 

But then, I am back to square one.  I end up viewing individuals who have more than one jobtitle (duplicates or more).

 
I may not be explaining this clearly but I am new to Crystal Report using ver 8.  I have tried playing with the outer joins but no joy.  I guess I am wondering if there is a formula to say that..
 

Even if an individual does not belong to an organisation (or have a null / blank record on their Main Contact/Organisation), it will still get pull out...
...as well as an individual who has a "Y" on their Main Contact/Organisation field.

 
and be able to export the final result onto Excel...(putting a subreport will bring the desire outcome (tweaked by a formula) but when exporting, there is no data from the subreport part which brings out the jobtitle on the main report).
 
 
Hence, I am asking if there is a formula to resolve this as Outer joins and nothing in the table fields I can find which will help achieve the desired outcome.
 

If clarification is needed, please ask. Apologise if this is not clear as I am still finding my way round through this work database (it's Integra if you are wondering).
 

Table - INDIVIDUAL
===============
Contact Ref
Individual
Organisation
and other fields

 
Table - CONTACT
======================
Contact Ref
Individual
Organisation
Jobtitle
Main Contact
Main Organisation
 

Many thanks!



Edited by wisdom - 08 May 2010 at 10:25am
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 08 May 2010 at 5:30pm

Maybe you can do this in crystal. You can definately suppress the unwanted rows but not remove them in the select expert. You were on the right track using the outer join but your select statement turns the outer join back into an inner one.

If you cannot do this as a view or stored proc you can try using a COMMAND to do a conditional outer join and an AND statement in the join for your condition (rather than a where statment that crsytal is doing after the join is applied)
select fields
from table1
left outer join table1.field=table2.field and table1.field and table1.field="Y"
IP IP Logged
wisdom
Newbie
Newbie


Joined: 08 May 2010
Online Status: Offline
Posts: 6
Quote wisdom Replybullet Posted: 12 May 2010 at 10:39pm
I am still struggling with this on version 8.  I cannot find a way to do as yo usuggested, maybe version 8 do not have this ability.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 17 May 2010 at 5:24am
Never used 8 so I am not sure. Do a search on COMMAND. IN later versions you access it in the Database Expert , available data sources. Once you select your source there is an Add Command in there.
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 17 May 2010 at 6:22am
I do not know about 8, but in 8.5 when you 'Show SQL Query', you can edit the query there.  Not sure how much it will let you do.
 
Also 'Command' is not avaible in 8.5 (and probably not in 8).
IP IP Logged
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