Counting only certain records in each group

M

Morgan Chong

I have a report with running sums over each group. Next,
I have a text box in the details section of the report
that compares the running sum to other data in each
record and says "Error" under certain conditions. I'm
trying to count the number of "Error"s in the group
footing. Using COUNT, I either get all counted, or
none. I tried making a counter in details (1
if "Error, " " or Null otherwise) and using SUM[Error
counter] in the footer, but get asked to enter a
parameter for [Error counter]. I also tried embedding
Iif into COUNT and got nowhere.
 
F

Fons Ponsioen

I think I need some more information to try to help. Like
what data are you working with, What is the formula
that "compares" running sums etc.
Be a bit more specific and maybe someone can help.
Fons
 
M

MOrgan Chong

OK, here's the details (I was trying to keep it simple)

I am reviewing stock trading activity. Each record
identifies the [traderID], [Stock Symbol], [trade date],
[trade time], [quantity], and whether the trader marked
the trade as a buy, sell, or short sell, expressed as
[order type]. The data in the report is grouped by
[traderID], then by [symbol], and then each trade is in
chronological order using [trade date] and [trade time].

I used running sums in a report to calculate [balance]
for each [stock symbol] group. I modified so that the
running sum subtracts instead of adds [quantity] to
[balance] if [order type]="sell" or "short sell".

By rule, if a trader has zero or fewer shares and sells
stock, he must mark the sale as "short sell". I am
reviewing for instances when [order type]="sell" occurs
that results in the running sum [balance] in the group
being negative, meaning that [order type] should have
been marked as "short sell" and is an error.

In the report, I have successfully made a calculated
control (or text box - not sure of proper terminology)
for each record when [order type]= "sell" but the running
sum [balance] is negative. If so, [check]="Error",
otherwise zero-length (I tried Null too).

Herein lies the problem: I'm looking at almost one
million trades in hundreds of stocks by a dozen traders
over a period of three months. (The report is 20,000
pages!) I have the errors flagged, but can't find a good
way to count up how many errors per trader automatically
in footers. I've tried =Sum, =Count, and records counts
that don't count Null, to no avail.

I have since read that Access can't do summary functions
in a report footer using a calculated control from a
report.

I can't seem to be able to compute [balance] in the
initial query because I need [balance] to reset to zero
at each change in [stock symbol].

Any help is greatly appreciated.



-----Original Message-----
I think I need some more information to try to help. Like
what data are you working with, What is the formula
that "compares" running sums etc.
Be a bit more specific and maybe someone can help.
Fons
-----Original Message-----
I have a report with running sums over each group. Next,
I have a text box in the details section of the report
that compares the running sum to other data in each
record and says "Error" under certain conditions. I'm
trying to count the number of "Error"s in the group
footing. Using COUNT, I either get all counted, or
none. I tried making a counter in details (1
if "Error, " " or Null otherwise) and using SUM[Error
counter] in the footer, but get asked to enter a
parameter for [Error counter]. I also tried embedding
Iif into COUNT and got nowhere.
.
.
 
F

Fons Ponsioen

Sorry it took a while but I have to earn a living also.
I don't claim to quite totally understanding all you
explained with espect to the stock trades, but here I go.
At the same place where you calculate the "Error" you
should also be able to calculate with an IIF statement for
the same condition that indicates error, so
=IIF([your calculation] = "Error",1,0)
and you can sum over the group,
This should give you the total number of "Errors" per each
group, if you wish you can do the same for over all.
I hope I answered your question and that this gets you
going.
Fons
-----Original Message-----
OK, here's the details (I was trying to keep it simple)

I am reviewing stock trading activity. Each record
identifies the [traderID], [Stock Symbol], [trade date],
[trade time], [quantity], and whether the trader marked
the trade as a buy, sell, or short sell, expressed as
[order type]. The data in the report is grouped by
[traderID], then by [symbol], and then each trade is in
chronological order using [trade date] and [trade time].

I used running sums in a report to calculate [balance]
for each [stock symbol] group. I modified so that the
running sum subtracts instead of adds [quantity] to
[balance] if [order type]="sell" or "short sell".

By rule, if a trader has zero or fewer shares and sells
stock, he must mark the sale as "short sell". I am
reviewing for instances when [order type]="sell" occurs
that results in the running sum [balance] in the group
being negative, meaning that [order type] should have
been marked as "short sell" and is an error.

In the report, I have successfully made a calculated
control (or text box - not sure of proper terminology)
for each record when [order type]= "sell" but the running
sum [balance] is negative. If so, [check]="Error",
otherwise zero-length (I tried Null too).

Herein lies the problem: I'm looking at almost one
million trades in hundreds of stocks by a dozen traders
over a period of three months. (The report is 20,000
pages!) I have the errors flagged, but can't find a good
way to count up how many errors per trader automatically
in footers. I've tried =Sum, =Count, and records counts
that don't count Null, to no avail.

I have since read that Access can't do summary functions
in a report footer using a calculated control from a
report.

I can't seem to be able to compute [balance] in the
initial query because I need [balance] to reset to zero
at each change in [stock symbol].

Any help is greatly appreciated.



-----Original Message-----
I think I need some more information to try to help. Like
what data are you working with, What is the formula
that "compares" running sums etc.
Be a bit more specific and maybe someone can help.
Fons
-----Original Message-----
I have a report with running sums over each group. Next,
I have a text box in the details section of the report
that compares the running sum to other data in each
record and says "Error" under certain conditions. I'm
trying to count the number of "Error"s in the group
footing. Using COUNT, I either get all counted, or
none. I tried making a counter in details (1
if "Error, " " or Null otherwise) and using SUM[Error
counter] in the footer, but get asked to enter a
parameter for [Error counter]. I also tried embedding
Iif into COUNT and got nowhere.
.
.
.
 
Top