Avatar billede trinerafn Nybegynder
03. oktober 2005 - 12:19 Der er 8 kommentarer og
1 løsning

Problem m sammentælling i Rapport

Jeg har en rapport dannet på en query. I rapportens Report Footer har jeg lavet et summeringsfelt hvor der står: =Sum ([OrderDateTotal])Det burde være meget godt, MEN hvis der er tillæg (poster fra den relaterede tabel)tæller den disse rækker med så hvis der SKULLE STÅ 100 så står der 400 hvis der er 3 poster med fra den relaterede tabel. Er der en function man kan bruge så den kun tager det tal med som den skal?
Avatar billede terry Ekspert
03. oktober 2005 - 12:29 #1
Hi Trine
isnt this because you have more than one related record and therefore the OrderDateTotal is getting displayed (summed) for all related records?

Maybe a solutionis to count how many records there are

=Sum ([OrderDateTotal])/Dcount(......
Avatar billede terry Ekspert
03. oktober 2005 - 12:37 #2
actually I think that you can use count()

=Sum ([OrderDateTotal]) /count([OrderDateTotal])


But I'm rather confused as to why you say it shows 400 for 3 records!
Avatar billede trinerafn Nybegynder
03. oktober 2005 - 14:14 #3
Hi Terry, sorry for my long reply. And yes you're right it shows 300 (not 400)in stead of 100. If I use count, it shows 3 for the three records it counts, but of course that isn't the number I need, I need a Sum of "OrderDateTotal" or a Sum of what we display on the report as "OrderIntake". I hope you can help me
Avatar billede terry Ekspert
03. oktober 2005 - 14:22 #4
You say that it shows 300 and if you use count it shows 3.

So I am assuimg that there are three records in the query and each record shows 100. Then in the report it shows 300 because it sums 100 * 3

So if we use

=Sum(OrderDateTotal) / Count(OrderDateTotal)
we should get 100

(300/3) = 100 ???

or am I missing something?
Avatar billede trinerafn Nybegynder
03. oktober 2005 - 15:08 #5
No, you're not missing anything, I however need to explain myself better, I will return tomorrow
Avatar billede trinerafn Nybegynder
04. oktober 2005 - 12:22 #6
Ok, now I'm back. Here's an example.
ProjNo 1110  Initial Amount    1000
Add1                  Amount    100
Add2                  Amount    200
Add3                  Amount    200
OrderIntake for ProjNo 1110 =  1500
ProjNo 1111  Initial Amount    4000
Add1                  Amount    1000
OrderIntake for ProjNo 1111 =  5000
I would like it to total the two "OrderIntake" totals (1500+5000) But the total on my report says 9500 when I use my first solution (=Sum([OrderDateTotal])and when I use your above solution the reports says 2375 because it divides 9500 with 4 rows. It should have said 6500 (5000+1500). So you see I have a problem
Avatar billede terry Ekspert
04. oktober 2005 - 16:26 #7
Hi Trine
If you make a new report usin the wizard I'm sure you can choose to add a field showing the number of records, just like you do with sum.

Then sum and count should be visble on the footer to each section. It should then be possible to find the correct footer which  when you use something like

=Sum(OrderDateTotal) / Count(OrderDateTotal)

will show the correct result.

Or maybe you could send me your dB and I can take a look?
Avatar billede trinerafn Nybegynder
05. oktober 2005 - 13:27 #8
Hi Terry,
Hvad skal jeg snart sige - other than: You've done it again. Thanks so much! I do understand it, but would never have been able to code it. So drop an answer
Mvh Trine
Avatar billede terry Ekspert
05. oktober 2005 - 18:03 #9
thanks Trine
If you can code in the code behind buttons then you can also code other places such as in a report. So your almost there :o)
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Dyk ned i databasernes verden på et af vores praksisnære Access-kurser

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester