Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Count Formula Post Reply Post New Topic
Author Message
PatrickMayer
Newbie
Newbie


Joined: 11 Oct 2010
Location: Switzerland
Online Status: Offline
Posts: 2
Quote PatrickMayer Replybullet Topic: Count Formula
     Posted: 11 Oct 2010 at 10:31pm
Hi
 
I'm lost with a count-formula for my report. Below u see the details of my report so far:
 
Basic-Statement:
SELECT
FES.HIST_ANZEIT,
FES.FET_FETID,
FES.FELDID,
FES.REGAL,
FES.LAGID
FROM emmi2.FES
WHERE FES.FELDID NOT IN
(SELECT TEK.POS_FELDID
FROM emmi2.TEK )
including the following date-selection:
{Basis-Statement.LAGID} = 'K1'
and
( {Basis-Statement.FET_FETID} = 'EP130'
or  {Basis-Statement.FET_FETID} = 'EP175'
or  {Basis-Statement.FET_FETID} = 'EP210')
 
count-formula 1:
if {Basis-Statement.FET_FETID} = 'EP130'
and
 {Basis-Statement.REGAL} = 1
then
count( {Basis-Statement.FELDID} )
 
count-formula 2 G1R1EP130_2:
{Basis-Statement.FET_FETID} = 'EP130'
and
 {Basis-Statement.REGAL} = 1
=> created a sum with following details
- typ of sum: count
- field to sum: G1R1EP130_2
 
Problem:
with both formuals, the result is always the total of free storageplaces for
{Basis-Statement.REGAL} = 1. so it seems like its not excluding the or  {Basis-Statement.FET_FETID} = 'EP175'
or  {Basis-Statement.FET_FETID} = 'EP210')
 
desired result:
- for every storageplace EP130, EP175, EP210 the total count of free storageplace in:
  • {Basis-Statement.REGAL} = 1
  • {Basis-Statement.REGAL} = 2
  • {Basis-Statement.REGAL} = 3
  • {Basis-Statement.REGAL} = 4
  • {Basis-Statement.REGAL} = 5
  • {Basis-Statement.REGAL} = 6
  • {Basis-Statement.REGAL} = 7
  • {Basis-Statement.REGAL} = 8
the report should look like the following:
                  gang 1                gang 2                gang 3                 gang 4
             regal1 regal 2      regal3 regal 4      regal5 regal 6      regal7 regal8
 
ep130   count   count        count   count        count   count       count   count
ep175   count   count        count   count        count   count       count   count
ep210   count   count        count   count        count   count       count   count 
 
i already tried with grouping n most other stuff as well as sub-reports, but nothing worked out... any help will be much appreciated.
 
thx
 
pad
 
 


Edited by PatrickMayer - 11 Oct 2010 at 10:33pm
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 12 Oct 2010 at 3:23am
where I think the disconnect is, is that CR will count every value when doing a count, irrespective of any other value.  You might try one of the versions of count that have restrictions/condition on it, but since I haven't used it, I don't know how it works.
 
Typically, what I would do is to create shared/global variables and increment them as I want based on the criteria.  Running totals might also work, but I don't use them...DBlank is the master there.
 
for the shared/global solution, you typically have 3 formulas for each variable, but you can combine 2 of them.
1) reset, all the variables can be reset at once, usually in a group header:
shared numbervar aVar := 0;
 
2) increment, typically in details
shared numbervar aVar;
if {Basis-Statement.FET_FETID} = 'EP130'
and
 {Basis-Statement.REGAL} = 1
then
  aVar := aVar + 1;
 
3) display, typically in a group footer
shared numbervar aVar
 
HTH
IP IP Logged
PatrickMayer
Newbie
Newbie


Joined: 11 Oct 2010
Location: Switzerland
Online Status: Offline
Posts: 2
Quote PatrickMayer Replybullet Posted: 12 Oct 2010 at 3:37am
thx for the hint, will try that
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 12 Oct 2010 at 3:58am
Originally posted by PatrickMayer

count-formula 1:
if {Basis-Statement.FET_FETID} = 'EP130'
and
 {Basis-Statement.REGAL} = 1
then
count( {Basis-Statement.FELDID} )
 
the running total version would be:
Name=whatever
field to summarize=FELDID
type=count
evaluate=use a formula
{Basis-Statement.FET_FETID} = 'EP130' and Basis-Statement.REGAL}=1
reset=
never, if this for a report total or
on a group, if you are looking for a group level count
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