Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Totals Incorrect: Newbie Question Post Reply Post New Topic
Author Message
khaines
Newbie
Newbie


Joined: 14 Dec 2011
Location: United States
Online Status: Offline
Posts: 10
Quote khaines Replybullet Topic: Totals Incorrect: Newbie Question
     Posted: 09 Jan 2012 at 8:43am
I'm creating a report, with, for simplicity sake, has three 'tables'.

Companies----------Interactions (Left Outer Join)
          \
           \
            -------Employees (Inner Join)


I've successfully created a report that looks like this:

                 Phone Calls   Emails Meetings    Total
Microsoft              3          2        1          6
Google                 1          1        1          3

However, when I add a 'column' to the Detail section that also counts how many employees there are, all of my totals go completely out the door. Baffled as to why. My report looks like:

     
                 Phone Calls   Emails Meetings    Total
Microsoft             72        132       21       225
Google               41          31        11       83

I want a report that looks like this:

               Phone Calls   Emails Meetings    Total        Total Employees
Microsoft              3          2        1          6               15
Google                 1          1        1          3               114



Edited by khaines - 09 Jan 2012 at 8:46am
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 09 Jan 2012 at 8:59am
your employees table was not enforced until you added a field from it.
Once that happened it 'enformced' the join, which created duplicate rows which are include din your counts or sums.
IP IP Logged
khaines
Newbie
Newbie


Joined: 14 Dec 2011
Location: United States
Online Status: Offline
Posts: 10
Quote khaines Replybullet Posted: 09 Jan 2012 at 9:01am
Many thanks. Can you tell me how to resolve?
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 09 Jan 2012 at 9:07am
Not sure how your raw data looks but in general when dealing with duplicate data rows you can use variable formulas or Running Totals to conditionally count or sum values.
I use Running Totals others prefer VAriable formulas.
Likekly you have grouped your data on Comapny.
likely in your raw data there is a primary key field for each row.
likely you can use that as your cue to "evaluate on change" of that field.


Edited by DBlank - 09 Jan 2012 at 9:08am
IP IP Logged
khaines
Newbie
Newbie


Joined: 14 Dec 2011
Location: United States
Online Status: Offline
Posts: 10
Quote khaines Replybullet Posted: 09 Jan 2012 at 9:14am
You're dead on - I grouped on Company and I inserted a formula that basically said: (If [Field] = "Phone Call" then 1) and then summed the Phone Calls (Emails, Meetings, etc)

While there is a primary key for each row, I didn't paint the entire picture in my example. There is (for the employees) a field that is TRUE/FALSE that is basically something like "Full-time Employee". I'm trying to write a formula that says (If [Field] = TRUE then 1) and them sums it.

So, it will really look like this
                        Full-time        Part-time    Total
Google                      2               1          3
Microsoft                   4               -          4


IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 09 Jan 2012 at 9:24am

create a RT

Name=PTcount
field to summarize=workerid
type=distinctcount
evaluate=use a formula
table.field='Part-time'
reset=on change of group (company)
place in group footer (neither RTs or Variable formulas work in headers)
 
create the next RT called 'FTcount' the exact same way but use a different evaluate formula
table.field='Full-time'
 
for phone calls
Name=PhoneCount
field to summarize=primarykey (from interactions)
type=distinctcount
evaluate=use a formula
table.field='Phone call'
reset=on change of group (company)
 
repeat with different contact types in the evaluation formula
 


Edited by DBlank - 09 Jan 2012 at 9:24am
IP IP Logged
khaines
Newbie
Newbie


Joined: 14 Dec 2011
Location: United States
Online Status: Offline
Posts: 10
Quote khaines Replybullet Posted: 09 Jan 2012 at 9:35am
Last question (for a while. RT? What is that?
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 09 Jan 2012 at 9:37am
RT means Running Total
In the field Explorer it is generally the 3rd option from the bottom (if the tree is not expanded)
Right click on it and select New to create one.


Edited by DBlank - 09 Jan 2012 at 9:42am
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 09 Jan 2012 at 9:41am

note that a lot of people also refer to variable formulas that do counts as "Running Totals". It is a different way to do the same sort of thing, are usually formula fields written to use shared variables. When reading other posts keep it in mind that you may need to tease out which 'Running Total' is being referred to.

IP IP Logged
khaines
Newbie
Newbie


Joined: 14 Dec 2011
Location: United States
Online Status: Offline
Posts: 10
Quote khaines Replybullet Posted: 20 Jan 2012 at 4:34am
I've been meaning to thank you. This was very helpful and I greatly appreciate your patience in explaining all of this to me.

Cheers.
IP IP Logged
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