G
Guest
Is there a way in a pivot table to calculate percentages of catagories based
on the total record?
on the total record?
Dale Fye said:Rose,
Yes, how easy it is will be dependent on your table structure.
I just created a table that contains Student_ID, Question_Num, and Response
columns. I then populated values for 4 students and 4 questions. I then
created my cross tab query. I would normally write this query as follows to
get the number of responses of each value (A, B, C, D) for each question.
TRANSFORM Count(T1.ID) AS CountOfID
SELECT T1.Question_Num
FROM tbl_Q_Resp AS T1
GROUP BY T1.Question_Num
PIVOT T1.Response;
But if you recognize that you can determine the contribution of a single
response to the grid as 1 / (# of responses to the question), then instead
of Counting the number of records that contribute to a "cell" in this
matrix, you can sum this new value and get the percentage of each response
over each question number.
TRANSFORM Sum(1/DCount("ID","tbl_Q_Resp","Question_Num = " &
[T1].[Question_Num])) AS Expr2
SELECT T1.Question_Num
FROM tbl_Q_Resp AS T1
GROUP BY T1.Question_Num
PIVOT T1.Response;
You could take this one step farther by wrapping the Sum( ) in a format,
like:
TRANSFORM Format(Sum(1/DCount("ID","tbl_Q_Resp","Question_Num = " &
[T1].[Question_Num])), "percent") AS Expr2
SELECT T1.Question_Num
FROM tbl_Q_Resp AS T1
GROUP BY T1.Question_Num
PIVOT T1.Response;
HTH
Dale
Rose said:Is there a way in a pivot table to calculate percentages of catagories
based
on the total record?
Rose said:Hi Dale,
Thanks for your help. My skill level is a bit below yours. Is there a way
to break your answer down in more simplistic terms. This is what I am trying
to do:
I have two fields’ country (Dropdown Text Field listing Countries) and
Individuals (Number field containing the amount of people from that Country).
Is there an easy way to do a percentage? I.e. How many people overall are
from a particular country?
--
Rose
Dale Fye said:Rose,
Yes, how easy it is will be dependent on your table structure.
I just created a table that contains Student_ID, Question_Num, and Response
columns. I then populated values for 4 students and 4 questions. I then
created my cross tab query. I would normally write this query as follows to
get the number of responses of each value (A, B, C, D) for each question.
TRANSFORM Count(T1.ID) AS CountOfID
SELECT T1.Question_Num
FROM tbl_Q_Resp AS T1
GROUP BY T1.Question_Num
PIVOT T1.Response;
But if you recognize that you can determine the contribution of a single
response to the grid as 1 / (# of responses to the question), then instead
of Counting the number of records that contribute to a "cell" in this
matrix, you can sum this new value and get the percentage of each response
over each question number.
TRANSFORM Sum(1/DCount("ID","tbl_Q_Resp","Question_Num = " &
[T1].[Question_Num])) AS Expr2
SELECT T1.Question_Num
FROM tbl_Q_Resp AS T1
GROUP BY T1.Question_Num
PIVOT T1.Response;
You could take this one step farther by wrapping the Sum( ) in a format,
like:
TRANSFORM Format(Sum(1/DCount("ID","tbl_Q_Resp","Question_Num = " &
[T1].[Question_Num])), "percent") AS Expr2
SELECT T1.Question_Num
FROM tbl_Q_Resp AS T1
GROUP BY T1.Question_Num
PIVOT T1.Response;
HTH
Dale
Rose said:Is there a way in a pivot table to calculate percentages of catagories
based
on the total record?
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.