Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Newbie Formula Help please Post Reply Post New Topic
Author Message
ctoledo
Newbie
Newbie
Avatar

Joined: 25 Feb 2010
Location: United States
Online Status: Offline
Posts: 6
Quote ctoledo Replybullet Topic: Newbie Formula Help please
     Posted: 25 Feb 2010 at 11:51am

I am new to Crystal so please bear with me. Confused I need to find conditional data, all from one table. I am to find data that matches w and x and then based on query results, find all data that matches y and z. It would be better explained if I illustrate. This is a simplified example of what the data looks like.

 

DocName            DocNumber       DocType              DocDate               DocID

DocJohn               54321                    6                              10/12/2008         ABC123

DocJohn               FC123                    1                              10/12/2008         ABC123

DocJohn               46581                    6                              10/12/2008         ABC123

DocDave              FC432                    1                              10/12/2008         ABC987

DocDave              87965                    6                              10/12/2008         ABC987

DocDave              57198                    6                              10/12/2008         ABC987

DocPhil                 46289                    1                              10/12/2008         ABC456

DocPhil                 17841                    6                              10/12/2008         ABC456

DocPhil                 69236                    6                              10/12/2008         ABC456

 

 

My report needs to find any “DocType” = “1“ AND “DocNumber” StartsWith “FC” and somehow save the “DocID” results. In this case we would end up only with “ABC123” and “ABC987”. I would then like to re-query the entire database and display all matching “DocID” records that have a DocType of “6”. So the resulting report would only display as follows:

 

DocName            DocNumber       DocType              DocDate               DocID

DocJohn               54321                    6                              10/12/2008         ABC123

DocJohn               46581                    6                              10/12/2008         ABC123

DocDave              87965                    6                              10/12/2008         ABC987

DocDave              57198                    6                              10/12/2008         ABC987

 

I hope this makes sense. I can only do this as 2 separate reports but don’t know how to use the Formula Editor to make this happen as one report. If anyone can help me with a starting point it would be greatly appreciated.



Edited by ctoledo - 25 Feb 2010 at 11:52am
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 25 Feb 2010 at 12:00pm
Do you mean you want to create 1 report and conditionally choose which select stement to run?
Do you know how to add parameters?


Edited by DBlank - 25 Feb 2010 at 12:00pm
IP IP Logged
ctoledo
Newbie
Newbie
Avatar

Joined: 25 Feb 2010
Location: United States
Online Status: Offline
Posts: 6
Quote ctoledo Replybullet Posted: 25 Feb 2010 at 12:49pm
The report cannot have parameters as it will be automatically scheduled. Yes, I want to create just one report. What's peculiar about query is that I see it as a 2 phase query. The first query will find the records that have a "DocNumber" with a StartsWith "FC" and "DocType" = "1" selection criteria and give me a list of "DocID" of the records that match. The second query will take these resulting "DocNumber" records and display all of them that have a "DocType" = "6" criteria. Dont know if I am making much sense here but the illustration I think does a good job.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 25 Feb 2010 at 12:55pm

I think I understand what you mean but your statment is a little unclear.

You mean you need to get the 'DocName's that meet criteria for statment 1 and then in in statment you want where statement1 docname exists AND of those the doctype=6, correct?
 
Can you write SQL view or Stored Procedures or do you have to do this all in crystal?
IP IP Logged
ctoledo
Newbie
Newbie
Avatar

Joined: 25 Feb 2010
Location: United States
Online Status: Offline
Posts: 6
Quote ctoledo Replybullet Posted: 25 Feb 2010 at 1:04pm
"You mean you need to get the 'DocName's that meet criteria for statment 1 and then in in statment you want where statement1 docname exists AND of those the doctype=6, correct?"

EXACTLY! Tongue Unfortunately, this is all Crystal. The DB is MS SQL 2005 but dodo not have views or stored procedures associated with this report. Are you suggesting that is the way to go? I hope I can still do this using Crystal alone but if not, please enlighten me. Although I am a Crystal newbie I do a pretty good job of learning may way through, just need a starting point. Thnx much, your replies thus far are very much appreciated.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 25 Feb 2010 at 1:18pm
I think it would be easier in views or sps but it can be done in crystal.
You can do it via a subreport or you can do it via suppression or you could likely write a Command to get the data down to what you want.
DO you have a prerfered process and do you have to do a ot of calculations on the data once you have it?
IP IP Logged
ctoledo
Newbie
Newbie
Avatar

Joined: 25 Feb 2010
Location: United States
Online Status: Offline
Posts: 6
Quote ctoledo Replybullet Posted: 01 Mar 2010 at 5:08am
So theoretically, if I create a view that accomplishes the first filter, I should be able to run the second filter on Crystal Report?
IP IP Logged
ctoledo
Newbie
Newbie
Avatar

Joined: 25 Feb 2010
Location: United States
Online Status: Offline
Posts: 6
Quote ctoledo Replybullet Posted: 01 Mar 2010 at 12:53pm
If you are still reading this, I created a SQL view that gives me the results of Step 1. By querying the view, I get the Step1 results I needed which is all DocID's that are Doctype=1 and DocNumber starts with "FC".. Now how do get Crystal to take the DocID's from the SQL View and pull all DocType=6 records with same DocID's from the Table? I started a new report with 2 connections. A connection to the actual table and also the new view but can't seem to put Step1 and Step2 together. Thnx.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 01 Mar 2010 at 1:38pm
out today but trying to help here and there.
alter your first view to only return the doc name grouped.
use this view as an inner join to the table (enforced both) in the report and use crystal select statement for doctype=6.


Edited by DBlank - 01 Mar 2010 at 1:40pm
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