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!

Problem with sum plz help

Status
Not open for further replies.
Sep 12, 2005
448
US
Hi All
Cr 9.0
ms sql
I have a formula that calculated the average
here are my formula
--------------------------------
@Daily_Red

if {TRANSACTION_HISTORY.POSTING_DATE} <={?End_Date}
and
{TRANSACTION_HISTORY.TRADE_CLASS} = "R"
then
round({TRANSACTION_HISTORY.GROSS_AMOUNT})
else
0
-----------------------------------------
then i create a summary of this formula

sum(@Daily_Red,Territory)

that's fine

then i create a work-day formula
---------------------------------
@work_Day
WhileReadingRecords;
Local DateVar Start := Date(year({?End_Date}),1,1); // place your Starting Date here
Local DateVar End := {?End_Date}; // place your Ending Date here
Local NumberVar Weeks;
Local NumberVar Days;
Local Numbervar Hol;
DateVar Array Holidays;

Weeks:= (Truncate (End - dayofWeek(End) + 1
- (Start - dayofWeek(Start) + 1)) /7 ) * 5;
Days := DayOfWeek(End) - DayOfWeek(Start) + 1 +
(if DayOfWeek(Start) = 1 then -1 else 0) +
(if DayOfWeek(End) = 7 then -1 else 0);

//Local NumberVar i;
//For i := 1 to Count (Holidays)
//do (if DayOfWeek ( Holidays ) in 2 to 6 and
//Holidays in start to end then Hol:=Hol+1 );

Weeks + Days //- Hol
--------------------------------
this gives me the # of work days

then i get the average from @Daily_Red and @work_Day
--------------------------------
@Average
{@Daily_Red}/ {@work_Day}
--------------------------
i get the right number so far so good

but when i want to get the sum of @Average
@total_Avg
sum({@Average)

i don't get the right amount of the formula @Average result

ex:
Daily_Red********Work_Day*******Average
15****************5***************3
30****************5***************6
45****************5***************9
when i do a sum of the Average i get 90 instead of 18
what i'm i doing wrong????????????

Thanks









Durango122
if it moves and should not used Duck Tape
if does not move and should used WD-40
 
got it fix
Thanks anyway

Durango122
if it moves and should not used Duck Tape
if does not move and should used WD-40
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top