Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calculating average

Status
Not open for further replies.

pacificpear

Programmer
Dec 27, 2004
25
0
0
US
Crystal Report 10/ SQl/XML

All the data in sql server is in string

I am having problems in calculating avergages of the given date.Following is the data
X Y Z Timestamp
700994 HA-astprod2a 25.30 2005-06-17 08:15:38.000
700994 HA-astprod2b 125.30 2005-06-17 08:15:38.000
700994 HA-branch2a 16.87 2005-06-19 08:15:38.000
700994 HA-branch2a 18.87 2005-06-19 08:15:38.000
701295 HA-branch2a 8.42 2005-06-17 08:15:38.000
701295 HA-branch2a 18.42 2005-06-17 08:15:38.000
701295 HA-branch2a 82.42 2005-06-19 08:15:38.000
701295 HA-branch2a 81.42 2005-06-19 08:15:38.000

expected result

: Average of column Z on the same date i.e

First I have to calculate the sum of 700994 on date 2005-06-17

So the date should be

X Y Z Timestamp
700994 HA-astprod2a 150.6 2005-06-17 08:15:38.000
700994 HA-branch2a 35.74 2005-06-19 08:15:38.000

And same for the other one"701295" too and then i have to calculate the average of both the days

i.e average of "700994" is "75.3"

can anyone help
Thanks
PP
 
Use Insert->Group and make it by the date.

Palce the Z column in the details, right click it and select Insert->Summary->Average and select the date for the summary location.

Right click it again and select the same type of summary operation, except make this for a grand total (that will be the average of the 2 days).

-k
 
i have to create two parameter with start date and end date. And all the calculation are done inside that parameter.
means:
1. It shows the all the value between those two parameter ie start date and end date.
2. calculte the sum of column Z
3. then it also shows the average of data

thanks

PP
 
Using a description for describe requirements doesn't really help that much.

I gave you a suggestion, and you didn't respond as to whether it worked or not, you just posted a description.

As for using a parameter, create the date range parameter, and in the Report->Edit Selection formula->Record place something like:

{table.date} = {?MyDateRangeParameter}

Otherwise my solution should stand for the averages.

If not, don't just start adding in new requirements, state whether the current solution worked, and if not, state what you returned and what you need.

-k
 
Try using the parameter as SV suggested and then insert a group on {table.x} and then a group on {table.date}. Then you should be able to right click on {table.Z} and choose insert summary on all group levels.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top