Posts: 7
Threads: 6
Joined: Feb 2011
Reputation:
0
02-03-2011, 01:11 PM
(This post was last modified: 02-03-2011, 02:13 PM by sravsand.)
In an excel sheet having many rows and columns, in this there are 2 columns those are
questionnumber | Answers
1 a
2 c
3 b
1 c
4 d
2 d
. .
. .
here my question is what is the percentage of answers for each question number,
Output ex:
QuestionNumber | a% | b%| c%| d%|
1 |50|0|50|0|
2 |0|0|50|50|
like this for all question numbers. and this result should be inserted in new excel sheet
Thanks inadvance
Posts: 6
Threads: 1
Joined: Feb 2011
Reputation:
0
02-03-2011, 03:31 PM
(This post was last modified: 02-03-2011, 03:42 PM by anandanlk.)
Hi,
Use the following logic
just store in another excel(just name the 1st row headers as No, A, B, C and D respectively-one time)
get the first row details from excel u have
for example 1 a means
so just add 1 to the 2nd column(A) of 1st Question
No A B C D
1 1
get 2nd row from ur excel
For ex 4 b means
so just add 1 to the 3rd column(B) of 4th Question
No A B C D
4 1
get 3rd row from ur excel
For ex 1 b means
so just add 1 to the 3rd column(B) of 1st Question
No A B C D
1 1 1
get 4th row from ur excel
For ex 1 b means
so just add 1 to the 3rd column(B) of 1st Question
No A B C D
1 1 2
likewise get all rows from ur excel and add values
finally the excel will look like following
No A B C D
1 1 2 2 0
2 2 2 0 0
3 1 1 2 1
Get total for each
No A B C D tot
1 1 2 2 0 5
2 2 2 0 0 4
3 1 1 2 1 5
Result
No A B C D tot A% B% C% D%
1 1 2 2 0 5 1/5*100 2/5*100 2/5*100 0
2 2 2 0 0 4 2/4*100 2/4*100 0 0
3 1 1 2 1 5
Note: if value is zero means dont divide. otherwise u will get zero divide exception
I hope u know how to access values from excel
Posts: 7
Threads: 6
Joined: Feb 2011
Reputation:
0
02-03-2011, 11:29 PM
we don't know how many rows in questionnumber, it may have many rows, i need just filter all the rows by question number and percentages of answers. In the answers field it may have true/false or A,B,c. Could u please write the script for it.
Thanks
sandeep