Percentage of inactive customers

A

Antonio

Hello, all...
I have a table (CustomerDB) with a CustomerID as the
primary key and a checkbox for the inactive customers.
What I would like to do is get the percentage of inactive
customers ((inactive customer / customerid)*100). Can
somebody help me with the coding? Thanks, Antonio
 
P

Patrick

Hi Antonio!

From that table you need 2 things:
1- get # of custumers.
Dim res,res2 As Long
res = DCount("CustomerID ", "CustomerDB")'For customerID
2- # of innactive custumers.
res2= DCount
("CustomerID ", "CustomerDB", "InacColumn=TRUE")
result=(res2 / res)* 100

msgbox result 'view results.

This should help you out.
HTH,
PAtrick
 
R

Ron Weiner

You can do this with a Query (SQL statement). Paste the SQL below into a
query and let'er rip. I assumed that your customer active field was named
active.

SELECT Format(Sum(IIf([Active],1,0))/Count([CustomerID]),"Percent") AS [Pct
Active], Format(Sum(IIf(Not [Active],1,0))/Count([CustomerID]),"Percent")
AS [Pct InActive]
FROM CustomerDB;

If you need additional help with this post the DDL for the the CustomerDB
table, and I will give it a go.

Ron W
 
A

Antonio

Thank you, Patrick. It worked.

Antonio
-----Original Message-----
Hi Antonio!

From that table you need 2 things:
1- get # of custumers.
Dim res,res2 As Long
res = DCount("CustomerID ", "CustomerDB")'For customerID
2- # of innactive custumers.
res2= DCount
("CustomerID ", "CustomerDB", "InacColumn=TRUE")
result=(res2 / res)* 100

msgbox result 'view results.

This should help you out.
HTH,
PAtrick

.
 

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