Cumulative sum

G

Guest

I would like to create a cumulative sum for a percentage.

At the moment the data looks like this:

Turnaround Count Percentage

3 173 57.7
5 91 30.3

I would preferably want to make it look like this:

Turnaround Count Percentage

3 173 57.7
5 91 88.0

My SQL is:

SELECT Qry_Data.Turnaround, Count(*) AS [Count], 100*Count(*)/(SELECT
COUNT(*) FROM Qry_data) AS Percentage
FROM Qry_Data
WHERE (((Qry_Data.Product)="DWS Standard") AND ((Qry_Data.Turnaround)>0))
GROUP BY Qry_Data.Turnaround;
 
G

Guest

Try As first query

SELECT Qry_Data.Turnaround
FROM Qry_Data
WHERE Qry_Data.Product="DWS Standard" AND Qry_Data.Turnaround>0


Second query based on the first one:
Select Turnaround, DCount("*","Qry_Data","[Turnaround]<=" & [Turnaround]) /
Dcount("*","QueryName")*100 As Percentage
From QueryName

You can do that with one query, but you'll need to add the criteria in the
first query to the DCount, so I think that it easier to do that with two
queries
 
G

Guest

Sorry , I forgot the GroupBy in the second query

Select Turnaround, DCount("*","Qry_Data","[Turnaround]<=" & [Turnaround]) /
Dcount("*","QueryName")*100 As Percentage
From QueryName
Group By Turnaround
--
Good Luck
BS"D


Ofer Cohen said:
Try As first query

SELECT Qry_Data.Turnaround
FROM Qry_Data
WHERE Qry_Data.Product="DWS Standard" AND Qry_Data.Turnaround>0


Second query based on the first one:
Select Turnaround, DCount("*","Qry_Data","[Turnaround]<=" & [Turnaround]) /
Dcount("*","QueryName")*100 As Percentage
From QueryName

You can do that with one query, but you'll need to add the criteria in the
first query to the DCount, so I think that it easier to do that with two
queries

--
Good Luck
BS"D


scubadiver said:
I would like to create a cumulative sum for a percentage.

At the moment the data looks like this:

Turnaround Count Percentage

3 173 57.7
5 91 30.3

I would preferably want to make it look like this:

Turnaround Count Percentage

3 173 57.7
5 91 88.0

My SQL is:

SELECT Qry_Data.Turnaround, Count(*) AS [Count], 100*Count(*)/(SELECT
COUNT(*) FROM Qry_data) AS Percentage
FROM Qry_Data
WHERE (((Qry_Data.Product)="DWS Standard") AND ((Qry_Data.Turnaround)>0))
GROUP BY Qry_Data.Turnaround;
 
G

Guest

Unfortunately, that isn't what I would like.

I will explain. Each row contains information for enquiries. Each enquiry
can be turned around in 3 days or less, 4 or 5 days or more than 5 days.

3 173 57.7
5 91 30.3

58% have been turned around in 3 days or less (= 3)
30% have been turned around in 4 or 5 days (= 5)
12% have been turned around in 6 days or more (= 0)

These are the correct percentages.

With your first query, you are excluding the zeros so I won't get the
correct percentages.

I put the following line in my original SQL

Perc: DCount("*","Qry_Data","[Turnaround]<=" &
[Turnaround])/DCount("*","Qry_data")*100

70% for 3 days
100% for 5 days

Ofer Cohen said:
Sorry , I forgot the GroupBy in the second query

Select Turnaround, DCount("*","Qry_Data","[Turnaround]<=" & [Turnaround]) /
Dcount("*","QueryName")*100 As Percentage
From QueryName
Group By Turnaround
--
Good Luck
BS"D


Ofer Cohen said:
Try As first query

SELECT Qry_Data.Turnaround
FROM Qry_Data
WHERE Qry_Data.Product="DWS Standard" AND Qry_Data.Turnaround>0


Second query based on the first one:
Select Turnaround, DCount("*","Qry_Data","[Turnaround]<=" & [Turnaround]) /
Dcount("*","QueryName")*100 As Percentage
From QueryName

You can do that with one query, but you'll need to add the criteria in the
first query to the DCount, so I think that it easier to do that with two
queries

--
Good Luck
BS"D


scubadiver said:
I would like to create a cumulative sum for a percentage.

At the moment the data looks like this:

Turnaround Count Percentage

3 173 57.7
5 91 30.3

I would preferably want to make it look like this:

Turnaround Count Percentage

3 173 57.7
5 91 88.0

My SQL is:

SELECT Qry_Data.Turnaround, Count(*) AS [Count], 100*Count(*)/(SELECT
COUNT(*) FROM Qry_data) AS Percentage
FROM Qry_Data
WHERE (((Qry_Data.Product)="DWS Standard") AND ((Qry_Data.Turnaround)>0))
GROUP BY Qry_Data.Turnaround;
 
G

Guest

I've used a DSUM instead :)






Ofer Cohen said:
Sorry , I forgot the GroupBy in the second query

Select Turnaround, DCount("*","Qry_Data","[Turnaround]<=" & [Turnaround]) /
Dcount("*","QueryName")*100 As Percentage
From QueryName
Group By Turnaround
--
Good Luck
BS"D


Ofer Cohen said:
Try As first query

SELECT Qry_Data.Turnaround
FROM Qry_Data
WHERE Qry_Data.Product="DWS Standard" AND Qry_Data.Turnaround>0


Second query based on the first one:
Select Turnaround, DCount("*","Qry_Data","[Turnaround]<=" & [Turnaround]) /
Dcount("*","QueryName")*100 As Percentage
From QueryName

You can do that with one query, but you'll need to add the criteria in the
first query to the DCount, so I think that it easier to do that with two
queries

--
Good Luck
BS"D


scubadiver said:
I would like to create a cumulative sum for a percentage.

At the moment the data looks like this:

Turnaround Count Percentage

3 173 57.7
5 91 30.3

I would preferably want to make it look like this:

Turnaround Count Percentage

3 173 57.7
5 91 88.0

My SQL is:

SELECT Qry_Data.Turnaround, Count(*) AS [Count], 100*Count(*)/(SELECT
COUNT(*) FROM Qry_data) AS Percentage
FROM Qry_Data
WHERE (((Qry_Data.Product)="DWS Standard") AND ((Qry_Data.Turnaround)>0))
GROUP BY Qry_Data.Turnaround;
 

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

Similar Threads


Top