Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Technical Questions
Message Icon Topic: Linking Issues Post Reply Post New Topic
Author Message
ChrisD
Newbie
Newbie


Joined: 27 Sep 2007
Location: United States
Online Status: Offline
Posts: 6
Quote ChrisD Replybullet Topic: Linking Issues
    Posted: 27 Sep 2007 at 8:56am
Hi. I'm new to this forum, and Crystal Reports as well. My company asked me to learn it to provide accurate reports from the company database about shipping, booking, and other things.
 
Thanks to The Crystal Reports Book, and my own tinkering - I have been rather successful creating simple single-form reports of my own idea.
 
However, the time has come that I need data from two forms. Having quite a few difficulties, unfortunately.
 
I have been creating a "Shipping/Receiving Daily Financial Report", which up until this time has only required one form. However, in order to report our true sales I need "Unit_Price" from another form. As it is I am using "Unit_Cost" for all formulas, which is good for Receiving as it shows what we payed for an item. However in order to accurately convey shipping, I need to use what we CHARGE for an item. That data isn't on the form I currently have in use.
 
There are several different forms which have "Unit_ID" in common with the current form I am working with, and I found a few which contain the "Unit_Price" I need. I figured I could just link up the Unit_IDs, put the new "Unit_Price" from the new form in the report - and it would figure out which ID's are which and spit out the price I need (Yes, The Unit_ID fields are EXACTLY the same.).
 
However, When I do this, it seems to dramatically alter EVERYTHING else on my report, in a broken sort of way. For some reason my "QTY_Shipped" changes to 25 all the way down, even though the new form doesn't even include such a field. Nearly all my other fields break in a similar way - Though it does look like it gives me the correct pricing.
 
Am I wrong in my idea on how this works? Can anyone point me to a page or reference that will aid me? Or just help explain to me where I am going wrong, or give ideas on how to bring that field I need over?
 
I have tried with both inner and outer left joining.
 
If you have any questions, just ask.
 
Thanks!
 
-Chris


Edited by ChrisD - 27 Sep 2007 at 8:56am
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 27 Sep 2007 at 11:14am
Glad that you find the site and book helpful. I'm thinking that your problem is that the database is most likely not normalized for the field you are linking to and you are getting a cartesian resultset. I cover this on page 416 of the new book, but basically it means that the Unit_ID field is probably linking multiple times to the other table you are joining with. This results in a report which suddenly has a huge page count and you see the same data repeated over and over. To fix this you need to analyze your data and make sure that the linking field only matches a single record in the other table. Sometimes this isn't possible when you are linking to a table of history transactions and you have a similar record for each date. In this is happenis to be your problem, you need to create a subquery that returns the distinct records of the last transaction (I cover this on page 433 of the book). But most likely, you just need to review your data and check that things are matching up one to one rather than one to many and throwing your data out of whack.
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
IP IP Logged
ChrisD
Newbie
Newbie


Joined: 27 Sep 2007
Location: United States
Online Status: Offline
Posts: 6
Quote ChrisD Replybullet Posted: 27 Sep 2007 at 1:17pm

Thanks for the quick and in-depth response.

Unfortunately I don't own the new book, only the complete reference for XI. As such those page references don't help much and I still am a bit confused.
 
I gather that Unit_ID is trying to link up to too many fields, but I thought that is why I only told it to link to itself?
 
My thought was.. If Unit_Id was called upon in the report, then Unit_Price from the second form.. It would see which Unit_ID it links to, then send over the price. I guess I was wrong.
 
I am still confused as to the solution though. How do I make sure I only get the response I am looking for, and get that Unit_Price over to my report, matched up to the Unit_IDs?
 
You said go threw the data... While I can do that, what am I looking for? Unit_ID's match up perfect. I wasn't aware it'd pull other things without linking them though.
 
Sorry for being so confusing with all this, and thanks again for the help!
 
-Chris
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 27 Sep 2007 at 1:26pm
Oh, I thought you were referring to my 'CR Encyclopedia' book. Anyway, you get a cartesian product when the ID field appears more than once in the table. Does the table that has the price only have one record for each ID field? I've seen problems where a table like this might have multiple price records for each Unit Id b/c it wants to track the price history. Thus, you link to the Unit ID field and the next thing you know the report blows up in size and there is repeated data everywhere. I don't know if this is your situation or not.
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
IP IP Logged
ChrisD
Newbie
Newbie


Joined: 27 Sep 2007
Location: United States
Online Status: Offline
Posts: 6
Quote ChrisD Replybullet Posted: 28 Sep 2007 at 6:13am
Heh, well I certainly feel and look the fool. The URLs for the two books are somewhat similar. Seems like I should take the dive and purchase your book though, if your helpful presence on the forums is any indication. Sorry about that.
 
Perhaps that is the case. I just tested it out again, 11 pages becomes 581. 70K in daily sales becomes .. Lets see here... 4 Million.
 
So it looks very much like that is the situation. How do I go about only pulling the prices for the order I need? I don't think there is any order number link ups to use.
 
I am using a Prophet 21 Database, if that helps/matters.
 
Thanks again for all the help, and sorry for the confusion. I'll see if I can get my company to finance me your book. ;)
 
-Chris
 
UPDATE/EDIT:
 
Hm, I found fields that helps it narrow down the link to only the prices I need. If you can still explain a good way to get a sub-querry that'd be nice though.
 
New problem, however; if you will grant me your insight.
 
I am trying to make a Shipping / Receiving comparison in a side by side bar chart. As such I need to pull information for both in order to have them both show in the chart. However now that I am trying to pull the unit PRICE, No received item shows up as they are unsold. It seems it just filters out all received items as they don't have a price yet.
 
Is it possible to have it still pull the received items, and just not apply the new unit price filter for them? Or would I need a sub-report or some such?
 
Ideally the end result is a day-by-day bar chart showing Received Value and Shipped Value side by side for each day.
 
Thanks.


Edited by ChrisD - 28 Sep 2007 at 6:20am
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 28 Sep 2007 at 9:46am
No worries about the URL mix-up. Unfortunately, there are a lot of "Crystal Book" type websites out there right now. Let's just try to make this one the best! 

Re the catesian product problem, the most common way I use to get around that problem is to create a View in SQL which uses the SQL DISTINCT keyword to create a table without all the duplicates. Then I link to that View. Hopefully this is an option for your situation. (I have no idea what Prophet 21 is, - although it reminds of of the Alias TV show....)

Re the shipping/receving comparison,why is it filtering out items that don't have a price? Do you have a price criteria in the record selection filter? Are you joining the tables and there isn't a record in the corresponding price table? If so, then I would do a LEFT OUTER JOIN so that it still uses products even when there isn't a matching record in the Price table.

Oh - and buying a copy of the book is always appreciated, though certainly not a requirement to use the site. 
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
IP IP Logged
ChrisD
Newbie
Newbie


Joined: 27 Sep 2007
Location: United States
Online Status: Offline
Posts: 6
Quote ChrisD Replybullet Posted: 02 Oct 2007 at 6:55am
Sorry for the late reply; had a long weekend. :)
 
Going to take me a while to take this as second nature it seems. Left Outer Join worked like a charm of course. Thanks for reminding me that it existed.
 
Still having some issues with duplicate entries, am looking into the DISTINCT now.
 
Thanks.
 
IP IP Logged
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.023 seconds.