Understanding

N

NotGood@All

I'm using this code to count things that happened each day of the week -
xSun: Count(IIf(Weekday([Collected])=1,1,Null)), it work fine, now, I want to
add up the money for each day but "SUM" does not work inplace of "COUNT" I
don't understand, would someone explain it to me, please??

Thank You Very Much
 
G

Graham Mandeno

Purely by chance, Sum will give you exactly the same result as Count in this
case.

This is because Count will count 1 for every 1 value (when Weekday=1) and 0
for every null value (other days). Sum will add up all the 1s, which will
give the same result as counting them.

You need to apply Sum to the field containing the amount you wish to sum:

xSun: Sum(IIf(Weekday([Collected])=1, [AmountCollected], Null)),

Have you considered using a crosstab query for this? Make
Weekday([Collected]) the column heading and Sum([AmountCollected]) the value
and you will get (up to) seven columns, one for each day of the week.
 
N

NotGood@All

Graham, thanks very much, the code worked correctly
--
NotGood@All


Graham Mandeno said:
Purely by chance, Sum will give you exactly the same result as Count in this
case.

This is because Count will count 1 for every 1 value (when Weekday=1) and 0
for every null value (other days). Sum will add up all the 1s, which will
give the same result as counting them.

You need to apply Sum to the field containing the amount you wish to sum:

xSun: Sum(IIf(Weekday([Collected])=1, [AmountCollected], Null)),

Have you considered using a crosstab query for this? Make
Weekday([Collected]) the column heading and Sum([AmountCollected]) the value
and you will get (up to) seven columns, one for each day of the week.

--
Good Luck :)

Graham Mandeno [Access MVP]
Auckland, New Zealand

NotGood@All said:
I'm using this code to count things that happened each day of the week -
xSun: Count(IIf(Weekday([Collected])=1,1,Null)), it work fine, now, I want
to
add up the money for each day but "SUM" does not work inplace of "COUNT"
I
don't understand, would someone explain it to me, please??

Thank You Very Much
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top