在一个列中计算区分大小写的条件,如果满足另一列中的条件。

huangapple go评论59阅读模式
英文:

EXCEL: Count case sensitive criteria in one column if meets criteria in another column

问题

我的参与者被问及“你是谁?”并被要求选择适用于他们的选项。我可能的答案列表如下:

教师
助教
特殊教育协调员
学校领导
教育心理学家
午餐监督员
学校其他员工
家长
研究员
学生
具有神经发育状况的人
其他

这导致一些参与者给出多个答案,如“教师,家长”或“学校其他员工,其他”。

我想要计算回答特定问题的参与者的每个答案的数量。这意味着我不能简单地编写一个公式来测试单元格是否等于条件,它必须是单元格包含文本,但区分大小写,同时还需要满足另一列的条件。

我使用以下公式来实现这一点(在这种情况下,R24指的是包含单词“教师”的单元格,公式的后半部分仅包括对我感兴趣的问题提供了回答的人)。

=COUNTIFS(Table1[[#All],[你是谁?]],"*"&R24&"*",Table1[[#All],[你学到的最有价值的东西是什么?]],"<>"&"")

这对于除“其他”之外的每个回答都有效。由于COUNTIFS不区分大小写,对于“其他”的总数包括那些还选择了“学校其他员工”的人。

在尝试解决这个问题时,我可以使用以下公式来产生区分大小写的总数(R35是包含单词“其他”的单元格,范围是包含类似下面的虚拟数据的一组数据)。

=SUMPRODUCT(--(ISNUMBER(FIND(R35,R39:R49)))

然而,我无法找到一种方法来添加额外的条件,即这只能计算回答问题的参与者,即在其他数据列中没有空白单元格(参见图像上的示例,其中包含用作问题回答的胡言乱语的列)。您将看到我的问题是,我的“其他”公式将包含“学校其他员工”的答案,因为COUNTIFS不区分大小写。

请注意,我在图像上给出的示例都在一个工作表上,而公式需要从其他工作表的大型数据集中提取数据。

英文:

My participants were asked 'who are you?' and asked to tick as many as applies to them. My list of possible answers are as follows:

Teacher
Teaching Assistant
SENCO
School Leader
Educational Psychology
Lunchtime Supervisor
School staff other
Parent
Researcher
Student
Person with neurodevelopmental condition
Other

This results in some participants producing responses with multiple answers like 'Teacher, Parent' or 'School staff other, Other'.

I want to count how many of each response there are for participants who answered a specific question. This means that I cannot simply write a formula that tests whether a cell = criteria, it must be that a cell contains the text, but be case specific, whilst also meeting criteria from another column.

I used the following formula to do this (R24 in this case referring to cell containing the word 'Teacher' and the latter part of the formula only including those who typed something in response to the question I am interested in).

=COUNTIFS(Table1[[#All],[Who are you?]],&quot;*&quot;&amp;R24&amp;&quot;*&quot;,Table1[[#All],[What was the most valuable thing that you learnt?]],&quot;&lt;&gt;&quot;&amp;&quot;&quot;)

This works fine for every response except 'Other'. As COUNTIFS is not case sensitive, the total produced for 'Other' includes that for those who also select 'School staff other'.

When trying to work this out, I can manage to produce a case sensitive total using the following formula (R35 being a cell containing the word 'Other' and the range being a set of dummy data like below):

=SUMPRODUCT(--(ISNUMBER(FIND(R35,R39:R49))))

Teacher, Parent
Teacher, Parent
Educational Psychology
SENCO, Other
Teacher
Other
School staff other
3
Other
SENCO, Other
School staff other, Other

However, I cannot find a way to add the additional criteria that this should only be counted for participants who answer the question i.e. do not have a blank cell in another column of data (see here for e.g. of dummy data including column of nonsense acting as answer to question, ignore % on left). You will see that my problem is that my formula for 'Other' counts the answer containing 'School staff other' as COUNTIFS is not case sensitive.

Please note that the example I give on the image is all on one worksheet whereas the formula needs to pull the data from a large dataset from other worksheets.

答案1

得分: 1

你可以尝试:

在一个列中计算区分大小写的条件,如果满足另一列中的条件。

公式在B1中:

`=MAP(A1:A12,LAMBDA(x,SUM(--ISNUMBER(SEARCH(", " & x & ",", ", " & E1:E11 & ",")))))

如果不支持,只需删除迭代的MAP(),但主要思想是你利用了多个答案以逗号和空格分隔的事实。利用这一点。

英文:

You may try:

在一个列中计算区分大小写的条件,如果满足另一列中的条件。

Formula in B1:

=MAP(A1:A12,LAMBDA(x,SUM(--ISNUMBER(SEARCH(&quot;, &quot;&amp;x&amp;&quot;,&quot;,&quot;, &quot;&amp;E1:E11&amp;&quot;,&quot;)))))

If not supported, just scratch the iterative MAP(), but the main idea here is that you are using the fact that multiple answers are comma-space delimited. Use this to your advantage.

huangapple
  • 本文由 发表于 2023年2月23日 22:30:26
  • 转载请务必保留本文链接:https://go.coder-hub.com/75546205.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定