Tricky Query . Any thoughts?

jstutz

Registered User.
Local time
Today, 19:07
Joined
Jan 28, 2000
Messages
80
At the risk of sounding like I haven't "done my homework," I'll post this question.

I'm using a crosstab query to produce a sales report that breaks out monthly revenue for the year. The query works great, but there's a hitch.

The way our sales dept "works," a sales month doesn't correspond to a calendar month. Instead, the days in one of our sales months is determined by the last sunday of the month, plus any trailing days from the previous month. As you may guess, this poses some date calculation problems. For ex. as far as sales is concerned, this October runs from Sept. 30 thru Oct. 28, even though a good majority of the rest of the world feels it runs from Oct 1st thru Oct 31st.
wink.gif


In my crosstab, I'm using a MONTH([Date]) function as the Column heading to break out the revenue by month. Since our sales dept. doesn't use a calendar month, my monthly totals are off.

What I need is a way to determine what SALES month the sale record should go on based on the sales date. I've tried creating a function to calculate this, but due to the high # of records in the sales table, it really bogs down my query.

I recently found a table in the database that details the sales calendar information. The records have an ID, Startdate, Enddate, a Year# and a Month#. For example, the record that contains information about the Oct 2001 sales month says:

ID#, 9/30/01, 10/28/01, 2001, 10

I should think I should be able use this query to determine what sales month my sales record belongs in, but since there isn't any relationship between the two the sales detail table and the date table, I'm at a loss. Anyone have any thoughts? I've looked into trying a Union query, but that doesn't seem to be what I need. Maybe I'm wrong.

If anyone has any suggestions, I'm all ears. If nothing else, I'll stick with the function I've already created, although I thought I could probably get better performance using the existing sales date table rather than the function.

Thanks in advance!
js
 
Our fiscal calendar is in a table, also.

My first thought is that you might want to include fiscal month and year in your sales record, since it would be used any period-based reporting and won't change unless the sales date changes.

In any case, I'd use a Dlookup to get it...something like this:
FiscalMon = DLookup("[MO_FISCAL]", "FISCAL_CALENDAR_TABLE", "([SalesDt]>= [DT_ACCTNG_MO_START] ) And ( [SalesDt] <= [DT_ACCTNG_MO_END]) ")

Another possibility...if you are running this report from a form, you can calculate the month beginning and ending dates in fields on the form (make these fields invisible and disabled), then use them directly in the selection criteria for your query.

[This message has been edited by Chris RR (edited 09-07-2001).]
 
DLookup... hadn't thought of that. I'll give that a try thanks!

Unfortunately, I'm pulling reports out of a 3rd party db, so I don't have the option to modify the tables, but I agree with you. The best way to solve this problem is to include the month and year in the sales table. Apparently an oversight in the db's design.

Thanks again.

js
 

Users who are viewing this thread

Back
Top Bottom