简体   繁体   English

具有多个命名范围的COUNTIFS的Excel公式

[英]Excel Formula for COUNTIFS with Multiple Named Ranges

I have an equation with this structure: =SUMPRODUCT(COUNTIFS(range1,crit1,range2,crit2,range3,namedrange1,range4,namedrange2)) 我有一个具有这种结构的方程式:= SUMPRODUCT(COUNTIFS(range1,crit1,range2,crit2,range3,namedrange1,range4,namedrange2))

It works when I remove 1 of the following groupings: (range3 and namedrange1), (range4 and namedrange2), (range1 and crit1), and it works if I enter single references from either of the named ranges. 当我删除以下分组之一时,它会起作用:(range3和namedrange1),(range4和namedrange2),(range1和crit1),并且如果我从任何一个命名范围中输入单个引用,它将起作用。 I went through evaluate formula, and it returns all 0s within the SUMPRODUCT, even though looking at the data I can plainly see that it should not return 0. Removing range2 and crit2 still returns 0 (it shouldn't return 0 here either). 我经过了评估公式,即使在查看数据的情况下,它仍然在SUMPRODUCT中返回全0,即使我清楚地看到它也不应该返回0。删除range2和crit2仍然返回0(这里也不应该返回0)。

Namedrange1 contains 3 entries and namedrange2 contains 34 entries. Namedrange1包含3个条目,namedrange2包含34个条目。

I've searched around on google, here and mrexcel and I can't seem to find a reason why this equation won't work. 我已经在google,此处和mrexcel上进行了搜索,但似乎找不到找到此等式无效的原因。 Any help is appreciated. 任何帮助表示赞赏。

I assume that both namedrange1 and namedrange2 are of the same vector type, ie both vertical ranges or both horizontal ranges? 我假设namedname1namedrange2都是相同的向量类型,即两个垂直范围还是两个水平范围?

In order to obtain your desired total, it will be necessary to make it so that one of these two ranges is orthogonal to the other. 为了获得所需的总数,必须使这两个范围之一与另一个正交。 As such, you can either set it up to this effect within your workbook, or else transpose one of the ranges in-formula, ie: 因此,您可以在工作簿中将其设置为此效果,也可以转置公式中的范围之一,即:

=SUM(COUNTIFS(range1,crit1,range2,crit2,range3,namedrange1,range4,TRANSPOSE(namedrange2)))

though note that this now requires committing as an array formula** . 不过请注意,现在这需要提交为数组公式**

For an explanation as to why such a transposition of one of the ranges is necessary, you might wish to read the following article: 有关为何需要对这些范围之一进行转置的解释,您不妨阅读以下文章:

https://excelxor.com/2014/09/28/countifs-multiple-or-criteria-for-one-or-two-criteria_ranges/ https://excelxor.com/2014/09/28/countifs-multiple-or-criteria-for-one-or-two-criteria_ranges/

Regards 问候

**Array formulas are not entered in the same way as 'standard' formulas. **数组公式的输入方式与“标准”公式的输入方式不同。 Instead of pressing just ENTER, you first hold down CTRL and SHIFT, and only then press ENTER. 首先按住CTRL和SHIFT,然后再按Enter,而不是仅按ENTER。 If you've done it correctly, you'll notice Excel puts curly brackets {} around the formula (though do not attempt to manually insert these yourself). 如果操作正确,您会注意到Excel在公式周围使用大括号{}(尽管不要尝试自己手动插入大括号)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM