Research data analysis in Excel: Median of x times column value

可紊 提交于 2019-12-08 13:29:00

问题


I need to analyze empirical research data.

Question      Fully agree (1)   Agree (2)    Neither(3)      Disagree (4) 
Q1                 7               3             2             5   
Q2                 10              7             0             0  
Q3                 4               3             3             7  
Q4                 15              0             2             0

So for Question Q1, 7 people fully agree, 4 agree, etc.

I have to calculate the median for all questions. The result should look like this:

Question      Fully agree (1)   Agree (2)    Neither(3)      Disagree (4)    Median
Q1                 7               3             2             5               2

Q2                 10               7             0             0               1

For Question Q1, 7 people answered with "fully agree", 3 with "agree", 2 with "Neither" and 5 with "Disagree". I want to calculate the Median of the Answers for Question Q1: "Fully agree" is equivalent to the number 1, "Agee" to 2, Neither to 3 and Disagree to 4. So all answers for Q1 would be: 1,1,1,1,1,1,1,2,2,2,3,3,3,4,4,4,4,4. The Median is: 2

For Q2 it is: 1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2. The median is 1

Usually I don't work with Excel, so all functions are new to me. I have now tried different solutions for several hours: e.g. VLOOKUP (Copy value N times in Excel)

Unfortunately I was not successful so far; maybe there is a very simple solution to calculate the median :). Hopefully a solution that is not based on VPA, as I have even less experience here. Thank you very much for your help


回答1:


Here's a fun way of doing it with a pretty simple formula:

=MID(REPT(1,B3)&REPT(2,C3)&REPT(3,D3)&REPT(4,E3),SUM(B3:E3)/2,1)

See the Explanation column,, that shows how I'm building a string consisting of all the values with REPT(1,B3)&REPT(2,C3)&REPT(3,D3)&REPT(4,E3). All I have to do then is extract the middle vallue, which is what the MID(Explanation,Number of entries / 2, 1)

If you have an even number of answers, and want to split the difference should say the middle point be between the values of 2 and 3, you can use this array-entered formula: =AVERAGE(VALUE(MID(REPT(1,B3)&REPT(2,C3)&REPT(3,D3)&REPT(4,E3),SUM(B3:E3)/2+ISEVEN(SUM(B3:E3))*{0,1},1)))




回答2:


I chose to repeat your single digit scores into a string and pluck out the median with MID and some maths.

=IF(ISODD(SUM(B2:E2)),--MID(REPT(B$1,B2)&REPT(C$1,C2)&REPT(D$1,D2)&REPT(E$1,E2),CEILING.MATH(SUM(B2:E2)/2),1), AVERAGE(--MID(REPT(B$1,B2)&REPT(C$1,C2)&REPT(D$1,D2)&REPT(E$1,E2), SUM(B2:E2)/2,1), --MID(REPT(B$1,B2)&REPT(C$1,C2)&REPT(D$1,D2)&REPT(E$1,E2), SUM(B2:E2)/2+1,1)))

I used custom number formatting so that the scores in B1:E1 could remain real numbers but you could hard-code the numbers into the REPT functions if you prefer true text labels.




回答3:


Is this what you want?

F3: =SUM(B3:E3)/2

G3: =SUM($B3:B3)

H3: =SUM($B3:C3)

I3: =SUM($B3:D3)

J3: =SUM($B3:E3)

K3: =IFERROR(MATCH(F3,G3:J3,1)+1,1)




回答4:


simply do:

=SUMPRODUCT({1,2,3,4},B2:E2)/SUM(B2:E2)

:)

EDIT:
ups... that's "mean"

best solution for median i was able to create was:

{=MEDIAN(IF(ROW(A1:INDEX(A:A,B2)),1),IF(ROW(A1:INDEX(A:A,C2)),2),IF(ROW(A1:INDEX(A:A,D2)),3),IF(ROW(A1:INDEX(A:A,E2)),4))}

but it will count "0" as 1 :(

or

{=MEDIAN(IF(B3,IF(ROW(A2:INDEX(A:A,B3)),1)),IF(C3,IF(ROW(A2:INDEX(A:A,C3)),2)),IF(D3,IF(ROW(A2:INDEX(A:A,D3)),3)),IF(E3,IF(ROW(A2:INDEX(A:A,E3)),4)))}

but that will count every 0 as a 0 :(

OK... this should work:

{=MEDIAN(IF(B3,IF(ROW(A2:INDEX(A:A,B3)),1),{0,5}),IF(C3,IF(ROW(A2:INDEX(A:A,C3)),2),{0,5}),IF(D3,IF(ROW(A2:INDEX(A:A,D3)),3),{0,5}),IF(E3,IF(ROW(A2:INDEX(A:A,E3)),4),{0,5}))}


来源:https://stackoverflow.com/questions/51457149/research-data-analysis-in-excel-median-of-x-times-column-value

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!