-Collapse +Expand
Paradox
Search Paradox Group:

Advanced
Paradox To/From
To/FromCODEGuides
Paradox Store
PRESTWOODSTORE

Prestwood eMagazine

April Edition
Subscribe now! It's Free!
Enter your email:

   ► MB LobbyCorel Paradox / ObjectPAL Coding BoardParadox Reports Topic   Print This     

Hi, The following code appear...

Hi, The following code appear... in Paradox Reports topic (part of our Corel Paradox / ObjectPAL Coding group).

Quick Search: following   Hi The   Hi The following   code appear  
Paul Castelow
Ashburton, New Zealand

Hi,

The following code appears in a undefined field on the record band of my report.

Sum([New.Number]*[New.Cost])

I wish to get the AVG of those calculations based on a Group Band.

How do I achieve this ?

Many thanks,

Paul

 Posted 15 years ago (Thread Starter)
Comment Quote
About Paul Castelow
Visit Profile
Approved member.
Member subscribes to this thread with a verified email.

Post ID #14546, 8 replies
Thread Started 4/9/2011 4:16:19 PM
View Counter=4017
Last Reply Posted 4/19/2011 4:58:47 PM)
Location=Ashburton, New Zealand  
Joined=25 years ago   MB Posts=128  
Daniel Fought
Prestwood IT
Home office in Fresno, CA.

You should be able to copy this field to the group band and change the defination to:

Sum([New.Number]*[New.Cost])/count([New.Number])

Dan Fought
Senior Programmer Analyst
Prestwood IT Solutions
http://www.prestwood.com

 Posted 15 years ago
Comment Quote
About Daniel Fought
Visit Profile
Approved member.
Member subscribes to this thread with a verified email.
About Daniel Fought
Danial Fought is a senior programmer analyst with Prestwood IT where he develops custom Windows software and custom websites. When Dan is not coding for clients, he participates in this online community. Coding specialties include Paradox/ObjectPAL, MS Access, Visual Basic, and VS.Net/VB.Net.

Post ID #14547 (Level 2) and Parent is 14546
Reply Posted 4/11/2011 5:58:57 AM
Location=Home office in Fresno, CA. 
Joined=24 years ago   MB Posts=401   KB Posts=12   KB Comments=4  
Paul Castelow
Ashburton, New Zealand

Thanks for your help Dan but the code I gave you totals ALL the recods, for example :- Rec1   (Number) 2  (Cost) 3

                 Rec2  (number) 1   (Cost) 1     TOTAL = 7

Now I want to get the AVG of these TOTAL Costs based on a Group Band.

Thanks for your interest to help.

Rds,

Paul

 Posted 15 years ago (Thread Starter)
Comment Quote
About Paul Castelow
Visit Profile
Approved member.
Member subscribes to this thread with a verified email.

Post ID #14549 (Level 3) and Parent is 14546
Reply Posted 4/11/2011 8:01:22 PM
Location=Ashburton, New Zealand  
Joined=25 years ago   MB Posts=128  
Daniel Fought
Prestwood IT
Home office in Fresno, CA.

Let me see if I understatnd your situation correctly.

Your report consists of a records grouped by some criteria.  You are calculating a sum of the records within the group but want to calculate the average of the calculated sums between the groups.

In this case the Average is going to be placed outside the group band and should look something like

Sum([New.Number]*[New.Cost])/count(your group criteria)

Dan Fought
Senior Programmer Analyst
Prestwood IT Solutions
http://www.prestwood.com

 Posted 15 years ago
Comment Quote
About Daniel Fought
Visit Profile
Approved member.
Member subscribes to this thread with a verified email.
About Daniel Fought
Danial Fought is a senior programmer analyst with Prestwood IT where he develops custom Windows software and custom websites. When Dan is not coding for clients, he participates in this online community. Coding specialties include Paradox/ObjectPAL, MS Access, Visual Basic, and VS.Net/VB.Net.

Post ID #14550 (Level 4) and Parent is 14546
Reply Posted 4/12/2011 4:56:25 AM
Location=Home office in Fresno, CA. 
Joined=24 years ago   MB Posts=401   KB Posts=12   KB Comments=4  
Paul Castelow
Ashburton, New Zealand

New.db Has the following fields :-Paddock,Crop,Date,Number,Cost. The first Group Band is based on Crop.  The second Group Band is based on Paddock The code Sum([New.Number]*[New.Cost]) tells me the total for each Paddock.  I am now wanting the AVG Total per Crop.

 Posted 15 years ago (Thread Starter)
Comment Quote
About Paul Castelow
Visit Profile
Approved member.
Member subscribes to this thread with a verified email.

Post ID #14551 (Level 5) and Parent is 14546
Reply Posted 4/12/2011 8:03:35 PM
Location=Ashburton, New Zealand  
Joined=25 years ago   MB Posts=128  
Paul Castelow
Ashburton, New Zealand

Please dont leave me in suspenders !

 Posted 15 years ago (Thread Starter)
Comment Quote
About Paul Castelow
Visit Profile
Approved member.
Member subscribes to this thread with a verified email.

Post ID #14557 (Level 6) and Parent is 14546
Reply Posted 4/17/2011 3:32:34 PM
Location=Ashburton, New Zealand  
Joined=25 years ago   MB Posts=128  
Daniel Fought
Prestwood IT
Home office in Fresno, CA.

I gather that the code Sum([New.Number]*[New.Cost])  is located outside the Crop group band and inside the Paddock group band.  If you copy this field and past it inside the Crop group band you will get a total for each crop within each paddock.  Then you can modify the code to Sum([New.Number]*[New.Cost]) /count(Date) to get an average.  I used date since this is most likely a unique value.  You man need to add a unique identifier to get an accurate count.  

If you are attempting to get the average of the crops you are going to need to take another approach.  The report you have described is sorting the data by paddock and then crops within the paddocks.  Getting the average by the Crops alone would require a different sorting possibly a seperate report altogether.  An alternative would be to run queries to get the summary results and then create a report based on the generated data.

Dan Fought
Senior Programmer Analyst
Prestwood IT Solutions
http://www.prestwood.com

 Posted 15 years ago
Comment Quote
About Daniel Fought
Visit Profile
Approved member.
Member subscribes to this thread with a verified email.
About Daniel Fought
Danial Fought is a senior programmer analyst with Prestwood IT where he develops custom Windows software and custom websites. When Dan is not coding for clients, he participates in this online community. Coding specialties include Paradox/ObjectPAL, MS Access, Visual Basic, and VS.Net/VB.Net.

Post ID #14559 (Level 7) and Parent is 14546
Reply Posted 4/18/2011 8:15:26 AM
Location=Home office in Fresno, CA. 
Joined=24 years ago   MB Posts=401   KB Posts=12   KB Comments=4  
Paul Castelow
Ashburton, New Zealand

I have altered the query to call up results based on a crop, eg Wheat.

The following code  :- Sum([SprayALL.Rate]*[SprayALL.UnitPrice])/UniqueCount([SprayALL.Paddock#]) -placed between the Group Band on CROP and PAGE correctly averages the totals ON EACH PAGE, but fails to avereage all totals on all pages when, placed between PAGE and REPORT.

Thanks for hanging in there for me !

 Posted 15 years ago (Thread Starter)
Comment Quote
About Paul Castelow
Visit Profile
Approved member.
Member subscribes to this thread with a verified email.

Post ID #14563 (Level 8) and Parent is 14546
Reply Posted 4/19/2011 3:38:35 PM
Location=Ashburton, New Zealand  
Joined=25 years ago   MB Posts=128  
Most Recent Post
Paul Castelow
Ashburton, New Zealand

Have just cracked it, -used an exclusive field in the table to use for the UniqueCount.

Thanks once again.

 Posted 15 years ago (Thread Starter)
Comment Quote
About Paul Castelow
Visit Profile
Approved member.
Member subscribes to this thread with a verified email.

Post ID #14565 (Level 9) and Parent is 14546
Reply Posted 4/19/2011 3:49:50 PM
Location=Ashburton, New Zealand  
Joined=25 years ago   MB Posts=128  

Revive Thread!

Add a comment to revive this old thread and make this archived thread more useful.

Write a Comment...
Full Editor
...
Sign in...

If you are a member, Sign In. Or, you can Create a Free account now.


Anonymous Post (text-only, no HTML):

Enter your name and security key.

Your Name:
Security key = P1213A1
Enter key:
Icon: A Post    Thread    Idea    Important!    Cool    Sad    No    Yes    Includes a Link...   
Thread #14546 Counter
4017
Since 4/9/2011
Go ahead!   Use Us! Call: 916-726-5675  Or visit our new sales site: 
www.prestwood.com


©1995-2026 Prestwood IT Solutions.   [Security & Privacy]