Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Technical Questions
Message Icon Topic: Formulas to Catagorize Data and Put into a Chart Post Reply Post New Topic
Page  of 3 Next >>
Author Message
chadbrewyet
Newbie
Newbie


Joined: 26 Oct 2010
Online Status: Offline
Posts: 22
Quote chadbrewyet Replybullet Topic: Formulas to Catagorize Data and Put into a Chart
    Posted: 08 Nov 2011 at 6:50am
In our database, we have a table of time logs that our technicians enter their time into.  For each time log, there is a Time Log Reason that must be selected.  I already have some formulas set up to look at the Reasons, then based on what reason is selected, apply the time from the Log to a specific category. 
 
For example,  here are some categories and the Reasons that would fall under them.
 
Invoiceable - "MAC", "Service", "Training"
Travel - "Travel"
Contract - "Warranty", "Customer Agreement"
Installation - "System Install", "System Training"
Lunch - "Lunch"
 
Here's where it gets confusing for me.  I'm trying to then categorize them even further from here.  Our Invoiceable, Contract, and Installation categories would be considered Billable so I would like to then lump all of that time into yet another category. 
 
I would then like to create a chart for each of our technicians to show the breakdown of Billable, Travel, and Installation time.  The chart would show the total amount of time for each category over a selected period of time but we would not need to see it for each individual day.
 
Thanks in advance.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 08 Nov 2011 at 8:00am
you can create anothe formula field to organize the data into the bill,travel,install category.
you can group on technician and put pie charts on the group headers to show the data as you want per technician.
also add a second group on datafield set to day to show the per day rows.
IP IP Logged
chadbrewyet
Newbie
Newbie


Joined: 26 Oct 2010
Online Status: Offline
Posts: 22
Quote chadbrewyet Replybullet Posted: 08 Nov 2011 at 10:31am
Great!  It looks like that's what I want.  Now the only problem that I'm having is that the chart values for the first technician are showing up in the chart for the 2nd, and the 2nd's in the 3rd, and so on.  I have the report grouped by Tech first and the chart is currently in the Group Header.  Placing it in the Footer shows no data.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 08 Nov 2011 at 10:46am
i usually create a groupheader1B and place the chart on it so it can be managed on its own. when a chart is placed in a group section it will only display from rows that are part of that group so there should be no way that data associated with tech A could be in with Tech B or vice versa.
Look at the detail rows inside the grouping and verify that each row is what you are expecting for the technician.
IP IP Logged
chadbrewyet
Newbie
Newbie


Joined: 26 Oct 2010
Online Status: Offline
Posts: 22
Quote chadbrewyet Replybullet Posted: 08 Nov 2011 at 11:12am
That's what I find confusing I guess.  I do have the chart placed into Group Header 1b and that's what I get. 
 
Just a little more info if that will help.  I have 2 groups in the report.  The first group is by Techand  Group 2 is by Log Start Date.  So I see each Tech on new page, then each day is broken up individually for each Tech.
 
Each days Logs are totaled up and categorized by a formula placed in the last Detail section and displayed in Group Footer 2.  Another Formula in Group Footer 2 then adds each days categorized totals and displays a total for the entire time period for the Tech in Group Footer 1.
 
I guess what's happening is that the values that the chart is using is being calculated too late in the report.  Is there any way around that?
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 08 Nov 2011 at 11:15am
sometimes values can be displayed in crosstabs and charts  as I believe they are created in the last data pass.
Are you using Previous() or next() in you calculations?
IP IP Logged
chadbrewyet
Newbie
Newbie


Joined: 26 Oct 2010
Online Status: Offline
Posts: 22
Quote chadbrewyet Replybullet Posted: 08 Nov 2011 at 11:25am
No.  Should I be? 
I'm doing simple addition based on the Log Reason.  If the Reason matches an If statement, it adds the time to a variable.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 08 Nov 2011 at 11:27am
Not necessarily, a lot of people do time calculations on changes from one row to the next becuase that is how their data is stored... using previous() and next() can limit some other options...
 
can you show me a few rows of data and how you are calcuating?


Edited by DBlank - 08 Nov 2011 at 11:31am
IP IP Logged
chadbrewyet
Newbie
Newbie


Joined: 26 Oct 2010
Online Status: Offline
Posts: 22
Quote chadbrewyet Replybullet Posted: 09 Nov 2011 at 3:19am

Here's some sample data.

 

 

LogKeyID             Tech      LogReason          LogHours             LogMinutes

 

1                            Chad      MAC                     1                            45

2                            Chad      Service                 0                            30

3                            Chad      Warranty             1                            15

4                            Chad      Lunch                   0                            30

5                            Chad      Travel                   1                            30

 

 

In the Details section, I am first converting the hours to minutes and adding the additional minutes to get the total number of minutes for the Log.   Then I am doing an If/Then statement on the LogReason and depending on the reason, applying the minutes to a NumberVar (L1Invoiceable, L1Contract, L1Lunch, etc.).  After all details for the day are run, it then adds the daily totals to an overall total in a formula that is in the Group Footer that is grouped on the LogDate.  That formula simply adds the L1 total to an L2 total.  The L1 and L2 totals are then converted and formatted into a HH:MM format and displayed on the report through another formula.

 

If you need to see the actual formulas I am using, I can post them but I may have to edit them a bit. (privacy and all)

 

Thanks for your help so far.



Edited by chadbrewyet - 09 Nov 2011 at 3:19am
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 09 Nov 2011 at 4:13am
i think for your charts you wil have to choose if you are going to display total hours or total minutes (easier) as you need to leave it a number value for caluations into the chart.
Here is one way to get what you are looking for.
create one formula for total minutes for the day
//row_minutes
({table.loghours}*60)+{table.logminutes}
create 2 formulas for your row level categorizations (like you already did)
//Bill_grouping
if {table.logreason} in ['MAC','Service','Training'] then 'Billable' else if {table.logreason} in ['Warranty','Lunch'] then 'Installation time' else if {table.logreason} in ['Travel']  then 'Travel Time'
Of course fix the like values to match what you want them to be.
do the same thing for your other categorization need
now you can group your data and insert a chart at any level and get what you want
Group on technician
add a group header1B
insert a chart into GH1B (say a pie chart)
in the data tab for on chnage of use then @Bill_grouping formula field
for show value(s) use the @row_minutes formula set as a SUM.
 
If you want to show totals for each sub category you can use a crosstab
it can be placed in any header or footer
do not insert any column (unless you want to - like a day breakout)
for row insert your other category formula field
for summarized field use the @row_minutes formula field again set to a SUM
if you want to convert this to display HH:MM
right click on the summarized field in the ct
select format field
select common tab
select display string formula and use this to convert ho it is displayed
totext(floor(currentfieldvalue/60),0,'00') + ':' + totext(remainder(currentfieldvalue,60),0,'00')
 


Edited by DBlank - 09 Nov 2011 at 4:14am
IP IP Logged
Page  of 3 Next >>
Post Reply Post New Topic
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



This page was generated in 0.046 seconds.