Need query to calculate on time deliveries as a percent

cturton

Registered User.
Local time
Today, 10:08
Joined
Apr 13, 2000
Messages
10
Hello:

This is for the purchasing guy at my client's office. He has 9 vendors he wants to track their on time delivery performance. The data comes from the purchase order tables in his accounting software, to which I've linked via ODBC.

So far so good. I've created a query to pull only those 9 vendors from his total population, then ask for the date range to query by date for the date range (start and end date), and use an expression to calculate the difference between the date wanted and date received so he can tell if the delivery was on time or not. (ex: date wanted: 3/10/06 date received 3/13/06. 3 days difference = late delivery)

The twist is he wants another field so he can mark whether he considers the delivery late or not depending on extenuating circumstances he keeps locked up in his cranium, despite what the date difference results tell him. So, I created a combo box and he can select "Yes" or "No." If he selects YES, a value of 1 is written to the table in that field, if he selects NO, a value of 2 is written to the same field.

So, I need the query to group by vendor, count the total number of entries for that month by that vendor, count the number of "1"s and express that total as a percent of total deliveries.

To summarize, vendor A had 8 deliveries, 5 were on time, meaning he had a 62.5% delivery score. Vendor B had 10 deliveries, 7 on time, meaning a 70% delivery score.

Sorry for the long winded explanation, but perhaps someone can assist. All help appreciated.
 
If he selects YES, a value of 1 is written to the table in that field, if he selects NO, a value of 2 is written to the same field.

Doesn't make sense.
Change that into the default values used by yes/no fields (-1 for yes, 0 for no).
Use the Count function to count per vendor.
Use -1*Sum(nameofyourYesNocolumn) to calculate the number of deliveries in time.

Use CInt(Sum(nameofyourYesNocolumn)/Count(*)*-1*10000)/100 AS Percentage to calculate deliveries in time as a percentage.

RV
 
Thanks for the reply

Hi:

OK, I understand this. I'll give it a shot. Looks like it could be the medicine for the pain:D
 

Users who are viewing this thread

Back
Top Bottom