Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Creating a Summary using a formula field Post Reply Post New Topic
Page  of 2 Next >>
Author Message
Ohmsy
Newbie
Newbie


Joined: 13 Jul 2010
Location: United States
Online Status: Offline
Posts: 7
Quote Ohmsy Replybullet Topic: Creating a Summary using a formula field
     Posted: 13 Jul 2010 at 3:02am
I want to get a sum of the total amount of days that's being calculated by my formula field. If I use the insert summary tool than it ask me to select a report field to summarize and doesn't give me the option to summarize a formula field.

Any help would be great!

I have crystal reports 2008
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 13 Jul 2010 at 3:32am

what is your formula for calculating the datediff?

IP IP Logged
Ohmsy
Newbie
Newbie


Joined: 13 Jul 2010
Location: United States
Online Status: Offline
Posts: 7
Quote Ohmsy Replybullet Posted: 13 Jul 2010 at 3:35am
Originally posted by DBlank

what is your formula for calculating the datediff?





NumberVar TotalDays;
NumberVar TotalWeekEndDays;
NumberVar SecondsTook;
NumberVar HoursTook;
NumberVar DaysTook;
StringVAR TimeTaken;

TimeTaken := "No Dates";
    
TotalWeekEndDays := (DateDiff( "ww", {#SoCommentDateRt},{#MemApptDateRt},2)*2);

// Calculate work days took



TotalDays := Round((DateDiff( "d", {#SoCommentDateRt},{#MemApptDateRt},2) - TotalWeekEndDays ),0);


HoursTook:= (DateDiff( "h", {#SoCommentDateRt},{#MemApptDateRt},2));

SecondsTook:= (DateDiff( "s", {#SoCommentDateRt},{#MemApptDateRt},2));





   
if SecondsTook = 0 Then
      TimeTaken := ("Open")

   else if (TotalDays) > 0 Then
       
      TimeTaken := (TotalDays & " Day/s")

   else if HoursTook > 0 Then

       TimeTaken := (HoursTook & " HOUR/S")
   
    else
        TimeTaken := ("15 minutes") ;   






I probably will edit it and have anything < 1 Day just rounded up to '1 day' and anything = 0 Seconds '0'

Edited by Ohmsy - 13 Jul 2010 at 3:37am
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 13 Jul 2010 at 3:40am
Your result is a string so it cannot be summed
or did I miss something?

Edited by DBlank - 13 Jul 2010 at 3:41am
IP IP Logged
Ohmsy
Newbie
Newbie


Joined: 13 Jul 2010
Location: United States
Online Status: Offline
Posts: 7
Quote Ohmsy Replybullet Posted: 13 Jul 2010 at 3:45am
Originally posted by DBlank

Your result is a string so it cannot be summed
or did I miss something?


So there is no possible way to sum a string?
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 13 Jul 2010 at 3:48am
Nope.
you will have to make a formula that returns a numeric value to sum on. Make sure you decide on one value type for time sums: seconds, minutes hours or days. If you mix them up your sum will be worthless.


Edited by DBlank - 13 Jul 2010 at 3:48am
IP IP Logged
Ohmsy
Newbie
Newbie


Joined: 13 Jul 2010
Location: United States
Online Status: Offline
Posts: 7
Quote Ohmsy Replybullet Posted: 13 Jul 2010 at 3:54am
If i changed my formula to


f SecondsTook = 0 Then
      TimeTaken := ("0")

   else if (TotalDays) > 0 Then
       
      TimeTaken := (TotalDays)

   else if HoursTook > 0 Then

       TimeTaken := ("1")
    
    else
        TimeTaken := ("1") ;   


Would that work?
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 13 Jul 2010 at 4:14am
This is not my best area but I believe not.
TimeTaken is still a stringvar. You would have to switch it to a NUmberVar and have your results by ) or 1 bot "0" or "1".
IP IP Logged
Ohmsy
Newbie
Newbie


Joined: 13 Jul 2010
Location: United States
Online Status: Offline
Posts: 7
Quote Ohmsy Replybullet Posted: 13 Jul 2010 at 4:59am
sorry for the spoon feeding but i'm new to all this, if I changed it to a numbervar instead of a stringvar would I still be able to get my results?
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 13 Jul 2010 at 5:33am
That depends on what you mean by 'results'.
You can always create a second formula field for numeric values and leave your original for text.


Edited by DBlank - 13 Jul 2010 at 5:33am
IP IP Logged
Page  of 2 Next >>
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