Data Connectivity
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Data Connectivity
Message Icon Topic: Creating a report with two queries Post Reply Post New Topic
Author Message
TEOA
Newbie
Newbie
Avatar

Joined: 05 Dec 2010
Location: United Kingdom
Online Status: Offline
Posts: 3
Quote TEOA Replybullet Topic: Creating a report with two queries
    Posted: 06 Dec 2010 at 12:11am
I am trying to create a report that will report the scrap generated accross a number of machines. This is easy enough
but I also want to add to the same report a result that looks at other machines and gathers the total Good qty
 
I have a table that has MAchine number, qood qty, scrap qty, run date & time and a number of other values.
 
What I want the report to show is :
 
SCRAP CREATED BY  MACHINE 502,505,510,547,727
GOOD QTY FROM machine 502,505,510,547
the table contains information about 70+ machines
 
 
This is an extract from the record selection part of the report
{wireact.wcnt_nbr}= ["502","505","510","547","727"] and {wireact.crtd_date} > DateAdd ("h",-24, DateTime (CurrentDate, Time (06,00,00)))
 
I have a formula that adds different types of scrap together to give me the total scrap
{wireact.scrp_setup}+{wireact.scrp_ip}+{wireact.scrp_cut}
 
I have a percentage forumula that gives me the percentage of scrap
(Sum ({@totalscrap})/Sum ({wireact.good_qty}))*100
 
 
I want to be able to do the Percentage sum based on the goodqty from only  machines  502,505,510 &547 leaving out the qty from 727.
 
Is this possible???
 
I hope everyone can follow my ramblings
 
Thanks
 
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 06 Dec 2010 at 3:38am
if you want to compare the output of a machine as percentage of this total...it is possible.
 
If you are using a stored procedure to gather the data, I would add a column and perform the sum there.
 
If you are joining straight to the tables, I would create a subreport that calculates the number you want and passes it back to the main report via a shared variable.  It would read all the data in the detail lines and increment the shared variable if the machine is not the one that you are after.
 
in subreport, a formula like, in detail section:
shared numbervar machineTotal;
 
if {table.MachineNo} <> 727 then
  machineTotal := machineTotal + {table.GoodScrap};
 
 
in the main report, where ever you want to display this percentage:
shared numbervar machineTotal;
 
(SUM({table.GoodScrap}, {grouping}) / machineTotal) * 100
 
HTH
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.031 seconds.