Hi,
Thanks for replying. Here is some more info.
The database has 24 turnover fields, ThisYear1 - ThisYear12 and LastYear1 to LastYear12. Period 1 is April and so on.
TurnOverLastMonth is a formula field where I do a select case on the current month and return the value of the previous months turnover.
The report uses 3 tables all linked on the Account field. I've only listed the fields I use for the report.
Accounts
Account (code)
Sales_Type (used in the selection query)
House_Account (used in the selection query)
Account_Ledger
Account (code)
Ledger (used in the selection query)
TurnOver_LY_1
.
.
TurnOver_LY_12
TurnOver_TY_1
.
.
TurnOver_TY_12
Addresses
Name (of account)
Rep
Unfortunately I can't change the database structure (it's MS SQL) at all as it is run by a software company and I only have read privileges.
Although I could get them to set up a view for me if that would help.
I don't really know a lot of SQL otherwise some of this could probably be done with that.
The report layout is as follows -
Group Header #1
Grouped by addresses.rep
@Acc Count
DistinctCount ({ACCOUNT_LEDGER.ACCOUNT}, {ADDRESSES.REP})
@AccNotOrdered
(it works wether i have the if then in there or not, i don't think it makes sense to have it but i thought i'd need something to count only if the turnover was 0. in fact i'm surprised the count actually gives the corect figure at all. )
Group Header #2
Grouped by @TurnOverLastMonth
This section is suppressed.
Details
Account TurnOverLastMonth
I only added the second group as it was the only way i could get the second distinctcount to work.
I hope that explains it a bit better.
Thanks