Excel 公式:计算调查统计数据

发布于 2024-09-06 06:28:26 字数 610 浏览 3 评论 0原文

我对 100 位用户进行了调查,并尝试计算一些统计数据。我的调查中的相关字段如下所示:

    Gender           Interests
B1: Male         D1: Running, Snowboarding, Mountain Bikes
B2: Male         D2: Programming, Running, Paintball
B3: Female       D3: Bowling, Gymnastics
B4: Male         D4: Rock Climbing, Running,

我需要计算对“跑步”感兴趣的男性的百分比。文本将始终以“Running”的形式出现在字符串中,但可能以不同的顺序出现。

到目前为止,我得到的是:

=SUM(
     COUNTIF(
             D1:D100,ISNUMBER(
                               SEARCH(D1:D100,"Running")
            )
      )
 )

请注意,我还没有考虑男性/女性标准。该表达式当前返回 0。

任何帮助将不胜感激。

I have a survey from 100 users and I'm trying to calculate some statistics. The relevant fields in my survey look something like this:

    Gender           Interests
B1: Male         D1: Running, Snowboarding, Mountain Bikes
B2: Male         D2: Programming, Running, Paintball
B3: Female       D3: Bowling, Gymnastics
B4: Male         D4: Rock Climbing, Running,

I need to calculate the % of Males that are interested in "Running". The text will always appear in the string exactly as "Running" but it may appear in a different order.

Here what I have so far:

=SUM(
     COUNTIF(
             D1:D100,ISNUMBER(
                               SEARCH(D1:D100,"Running")
            )
      )
 )

Notice I haven't factored in the Male/Female criteria yet. This expression is currently returning a 0.

Any help would be greatly appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

你的呼吸 2024-09-13 06:28:26

解决这个问题的一个简单方法是稍微分解一下你的计算。

在另一列中,使用如下公式:

=IF(AND(B1="Male",ISNUMBER(SEARCH("Running",D1))),1,0)

对于所有将“跑步”列为兴趣的男性,这将为您提供 1,而对于所有其他人,则为 0。将其一直复制到工作表中,然后很容易计算百分比,例如,如果列是 E:

=SUM(E1:E100)/100

An easy way to approach it would be to break up your calculations a little.

In another column use a formula like this:

=IF(AND(B1="Male",ISNUMBER(SEARCH("Running",D1))),1,0)

This will give you a 1 for everyone who is Male and has "Running" listed as an interest and a 0 for all others. Copy that all the way down your sheet and then it's easy to calc the percentage, for example if the column was E:

=SUM(E1:E100)/100
耳根太软 2024-09-13 06:28:26

您还应该测试一下这个比例(喜欢跑步的男性的百分比)是否是侥幸。

您可以进行(皮尔逊或似然比)卡方检验来查看比例是否与预期不同。

例如,您还可以进行费舍尔精确检验来查看性别之间的比例是否不同。

You should also test to see if this proportion (% of men that like running) is by fluke or not.

You can do a (Pearson or Likelihood Ratio) Chi-Square test to see if the proportions are different from expected.

You can also do Fisher's Exact Test to see, for example, if the proportion is different between genders.

倾听心声的旋律 2024-09-13 06:28:26

您可以使用 Excel 和 ADO 做很多事情。

Dim cn As Object
Dim rs As Object
Dim sFile As String
Dim sCn As String
Dim sSQL As String
Dim s As String, f As String
Dim sa As Variant
Dim i As Integer, c As Integer
Dim r As Range

''This is not the best way to refer to the workbook
''you want, but it is very conveient for notes
''It is probably best to use the name of the workbook.

sFile = ActiveWorkbook.FullName

sCn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & sFile _
    & ";Extended Properties=""Excel 8.0;HDR=Yes;IMEX=1"";"

Set cn = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.Recordset")

cn.Open sCn

sSQL = "SELECT interests " _
       & "FROM [Sheet1$] "

rs.Open sSQL, cn, 3, 3

With Worksheets("Sheet2")
    s = rs.GetString(, , , ",")
    sa = Split(s, ",")

    c = 1
    For i = 0 To UBound(sa)
        Set r = .Range("a1:a" & c)
        f = Trim(sa(i))
        If r.Find(f) Is Nothing Then
            c = c + 1
            .Cells(c, 1) = f
        End If
    Next

    .Cells(1, 1) = "Interests"
    .Cells(1, 2) = "Male"
    .Cells(1, 3) = "Female"

    For i = 2 To c
        rs.Close

        sSQL = "SELECT Gender, Count(Gender) As GNo " _
             & "FROM [Sheet1$] " _
             & "WHERE Interests Like '%" & .Cells(i, 1) & "%' " _
             & "GROUP BY Gender"

         rs.Open sSQL, cn

         Do While Not rs.EOF
            If rs.Fields("Gender") = "Male" Then
                .Cells(i, 2) = rs.Fields("GNo")
            ElseIf rs.Fields("Gender") = "Female" Then
                .Cells(i, 3) = rs.Fields("GNo")
            End If
            rs.MoveNext
        Loop

        Next

End With

''Tidy up
rs.Close
Set rs = Nothing
cn.Close
Set cn = Nothing
End Sub

You can do a lot with Excel and ADO.

Dim cn As Object
Dim rs As Object
Dim sFile As String
Dim sCn As String
Dim sSQL As String
Dim s As String, f As String
Dim sa As Variant
Dim i As Integer, c As Integer
Dim r As Range

''This is not the best way to refer to the workbook
''you want, but it is very conveient for notes
''It is probably best to use the name of the workbook.

sFile = ActiveWorkbook.FullName

sCn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & sFile _
    & ";Extended Properties=""Excel 8.0;HDR=Yes;IMEX=1"";"

Set cn = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.Recordset")

cn.Open sCn

sSQL = "SELECT interests " _
       & "FROM [Sheet1$] "

rs.Open sSQL, cn, 3, 3

With Worksheets("Sheet2")
    s = rs.GetString(, , , ",")
    sa = Split(s, ",")

    c = 1
    For i = 0 To UBound(sa)
        Set r = .Range("a1:a" & c)
        f = Trim(sa(i))
        If r.Find(f) Is Nothing Then
            c = c + 1
            .Cells(c, 1) = f
        End If
    Next

    .Cells(1, 1) = "Interests"
    .Cells(1, 2) = "Male"
    .Cells(1, 3) = "Female"

    For i = 2 To c
        rs.Close

        sSQL = "SELECT Gender, Count(Gender) As GNo " _
             & "FROM [Sheet1$] " _
             & "WHERE Interests Like '%" & .Cells(i, 1) & "%' " _
             & "GROUP BY Gender"

         rs.Open sSQL, cn

         Do While Not rs.EOF
            If rs.Fields("Gender") = "Male" Then
                .Cells(i, 2) = rs.Fields("GNo")
            ElseIf rs.Fields("Gender") = "Female" Then
                .Cells(i, 3) = rs.Fields("GNo")
            End If
            rs.MoveNext
        Loop

        Next

End With

''Tidy up
rs.Close
Set rs = Nothing
cn.Close
Set cn = Nothing
End Sub
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文