Print Page | Close Window

Running Total of a Formula

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=18416
Printed Date: 01 May 2024 at 12:49pm


Topic: Running Total of a Formula
Posted By: chadbrewyet
Subject: Running Total of a Formula
Date Posted: 10 Jan 2013 at 7:23am
I am having trouble getting a running total to work on a formula.

I have a formula that rounds the amount of time on a time entry. My database has the time entry broken into 2 fields: tblTime.hours and tblTime.minutes. I also need to convert the hours to minutes. I have the conversion and rounding working but here's an explination of what is happening.

If tblTime.hours is 0, then I need @RoundedMinutes to always round up to 60 unless tblTime.minutes is also 0. If tblTime.hours in not 0, then @RoundedMinutes value should round up to 30 unless tblTime.minutes is over 30 in which case it should round up to 60. So, in a nutshell, 0hr 45min should = 60min, 1hr 10min should = 90min, and 1hr 50min should = 120min.

Like I said, that is all working. I would like to do a running total sum on that conversion. I've placed the formula field in the Details section so that it converts that particular entry. However, if I go to create the Running Total, my formula field is not listed in the available fields.

Is there a way to do a running total on the formula the way I have it set up? Or should it be in a different area of the report?

Any help is appreciated.

Thanks.



Replies:
Posted By: DBlank
Date Posted: 10 Jan 2013 at 7:47am
what is your formula?
Certain things used in a formual preclude it from being available for use in a RT.
also you need to leave your data as raw minutes to sum them. You can't sum "1 hour and 30 minutes"


Posted By: chadbrewyet
Date Posted: 10 Jan 2013 at 8:48am
Thanks for the reply. I am converting everything to raw minutes and the formula I am using to do the rounding is below. I will be taking the totaled minutes and convert and format the time as HH:MM as part of another formula later in the report. I'm just having trouble getting the Running Total to work in order to format it.



WhilePrintingRecords;

NumberVar TotalMinutes;
NumberVar RoundedMinutes;


If ({tblTime.hours} = 0) and ({tblTime.minutes} > 0)
        Then RoundedMinutes := 60
        Else If ({tblTime.minutes} <= 30)
            Then If ({tblTime.minutes} = 0)
               Then RoundedMinutes := 0
                    Else RoundedMinutes := 30
               Else Roundedminutes := 60;
              

TotalMinutes := TotalMinutes + ({tblTime.hours} * 60) + RoundedMinutes


Posted By: DBlank
Date Posted: 10 Jan 2013 at 9:16am

well it seems you already have it set as a "manual" running total unless you are resetting TotalMinutes on another detail section (or a header/footer) somewhere else.

to get it to appear as an option to be used in crystal's standard runnnig total change it to
 
if {tblTime.hours}=0 and {tblTime.minutes}>0 then 60 else
ceiling(({tblTime.hours}*60) + {tblTime.minutes},30)



Print Page | Close Window