Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Subreports & Formulas Post Reply Post New Topic
Page  of 2 Next >>
Author Message
MrCastalum
Newbie
Newbie
Avatar

Joined: 11 Mar 2010
Location: United Kingdom
Online Status: Offline
Posts: 22
Quote MrCastalum Replybullet Topic: Subreports & Formulas
     Posted: 11 Mar 2010 at 6:58am
I am using Crystal Reports XI.

Ok, so I have a total in my main report, and a total in a subreport. (Nothing in the subreport except the total.) The main report total is scrapped parts, the subreport total is total parts made (including scrap), so I want to show what percentage of total parts made is scrap. Can you tell me how to do this simply, as I am thick.
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 11 Mar 2010 at 7:35am
It probably would be best to create a shared variable in both the subreport and the main report (same name).  Assign the total in the subreport to the shared variable, then use that shared variable to calculate the percentage.
 
I hope this helps.
IP IP Logged
MrCastalum
Newbie
Newbie
Avatar

Joined: 11 Mar 2010
Location: United Kingdom
Online Status: Offline
Posts: 22
Quote MrCastalum Replybullet Posted: 11 Mar 2010 at 7:57am
How do I create a shared variable?

How do I assign the total in the subreport to the shared variable?
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 11 Mar 2010 at 11:04am
You would have a formula similiar to this:
 
shared numbervar total_parts := {#TotalPartsRunningTotal};
 
Then you would have a formula in the main report where the variable total_parts is defined (a formula to do the percentage).
 
shared numbervar total_parts;
IP IP Logged
MrCastalum
Newbie
Newbie
Avatar

Joined: 11 Mar 2010
Location: United Kingdom
Online Status: Offline
Posts: 22
Quote MrCastalum Replybullet Posted: 15 Mar 2010 at 3:47am
Thanks for this, haven't got it working yet though. I have created a formula in the subreport that is "shared numbervar total_made := {ProductionHistory.Qty} and this will show the correct qty but if I create a formula (in the subreport) that is just "shared numbervar total_made" I just get a load of zeros? (0.00)
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 15 Mar 2010 at 8:10am

So you have two formulas in the subreport.  One that has the assigment, and one just to show the value?  If so, what I normally do (just out of habit, do not know if it is necessary), in the formula for showing, I would have the following.

shared numbervar total_made;
total_made;
 
I hope this helps.
IP IP Logged
MrCastalum
Newbie
Newbie
Avatar

Joined: 11 Mar 2010
Location: United Kingdom
Online Status: Offline
Posts: 22
Quote MrCastalum Replybullet Posted: 15 Mar 2010 at 11:36pm
thanks, I figured out that the formula that was showing the display wouldn't work unless the formula that had the assignment was actually inserted into the report.

Now though, I can't get 'shared variable total_made;' to show in the main report? That's exactly the formula I'm using.
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 16 Mar 2010 at 6:35am
I am not sure why the
shared numbervar total_made;
total_made;
 
is not working.  It has always worked for me?!?
IP IP Logged
MrCastalum
Newbie
Newbie
Avatar

Joined: 11 Mar 2010
Location: United Kingdom
Online Status: Offline
Posts: 22
Quote MrCastalum Replybullet Posted: 16 Mar 2010 at 11:35pm
hmmm, it definitely isn't though. If I just insert into the subreport the formula 'Display' which is:

shared numbervar total_made;
total_made;

I just get '0.00' in the preview. Noticeably I get the same amount of '0.00's as I get the correct amount (i.e. 223,355) if I insert the formula 'Variable':

shared numbervar total_made := Sum ({Productionhistory.Qty});

So it seems to be picking up the data but not showing it??? i.e. both 'Variable' and 'Display' give me 8 pages of data but the one shows me 223,355, and the other 0.00?



Edited by MrCastalum - 16 Mar 2010 at 11:36pm
IP IP Logged
MrCastalum
Newbie
Newbie
Avatar

Joined: 11 Mar 2010
Location: United Kingdom
Online Status: Offline
Posts: 22
Quote MrCastalum Replybullet Posted: 21 Mar 2010 at 11:43pm
Just wanted to say that despite some more poking around this still isn't working. Anyone got any ideas?
IP IP Logged
Page  of 2 Next >>
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