简体   繁体   English

带有SUM的Google表格上的RANK IF公式

[英]RANK IF formula on Google Sheets with SUM

I am trying to create a ranking of summed numbers out of a database. 我正在尝试从数据库中创建一个汇总数字的排名。 The Database has a list of individual offices of companies in certain countries (numbered 1-10). 该数据库列出了某些国家/地区中公司的各个办事处(编号为1-10)。 In some cases, the same company is in multiple countries. 在某些情况下,同一家公司在多个国家/地区。 Countries are listed in Column A; 国家在A栏中列出; Companies are in column B; 公司在B列中; Offices are in column C. 办公室在C列中。

Each individual office has a score. 每个办公室都有一个分数。 Office scores are in column D of the database. 办公室得分在数据库的D列中。

I would like to create a rank of companies based on the company's total score per country. 我想根据公司在每个国家/地区的总得分来排名公司。 The company's total score per country is the sum of scores of all offices of the same company in the same country. 公司在每个国家/地区的总分是同一公司在同一国家/地区的所有办事处的总分。

In order to build such a ranking one would have to: 为了建立这样的排名,必须:

1 - Get the company's total score per country. 1-获取每个国家/地区的公司总得分。 I have done this using a SUMIFS function. 我已经使用SUMIFS函数完成了此操作。 This is the function I've used to calculate this score: =SUMIFS($D$2:$D, $A$2:$A, $A2, $B$2:$B, $B2) . 这是我用来计算分数的函数: =SUMIFS($D$2:$D, $A$2:$A, $A2, $B$2:$B, $B2) This is calculated in column E of the database. 这是在数据库的E列中计算的。

2- Rank it against the list of other companies' total score per country only for those companies that are in the same country. 2-仅针对同一国家/地区的公司,将其与其他国家/地区的公司总分进行比较。

I am having trouble defining the range for the RANK and have learnt that this is not possible to do using a function like this. 我在定义RANK的范围时遇到了麻烦,并且了解到使用这样的函数无法做到这一点。 The range against which to rank the value calculated on step 1 needs to be a conditional sum as well - the sum of all scores in the country of the office we are ranking. 步骤1所计算的值的排名范围也必须是有条件的总和-我们要排名的国家/地区中所有分数的总和。 How can this be done? 如何才能做到这一点?

After doing some research, I have tried solutions involving SUMPRODUCT and COUNTIFS but have failed to achieved the desired result. 在进行了一些研究之后,我尝试了涉及SUMPRODUCTCOUNTIFS解决方案,但未能获得理想的结果。 How can I do this? 我怎样才能做到这一点?

I have created a sample shee t here that might help to understand the problem here . 我在这里创建了一个示例表 ,可能有助于理解这里的问题。

Thank you 谢谢

If you want to be able to rank them, you 1st have to find and sort all the values for the current country. 如果要对它们进行排名,则必须首先找到当前国家/地区的所有值并将其排序。
Like @|'-'|, I used a query: 像@ |'-'||一样,我使用了一个查询:

=QUERY($A$2:$E;"select E WHERE A="&A2&" ORDER BY E DESC")

Since the same number can apear twice, you want to add a UNIQUE around that. 由于相同的数字可以出现两次,因此您要在此周围添加一个UNIQUE Be carefull, if 2 companies have the same score, they'll have the same rank. 请注意,如果2个公司的得分相同,则它们的排名也会相同。

=UNIQUE(QUERY($A$2:$E;"select E WHERE A="&A2&" ORDER BY E DESC"))

This will return the range, sorted from the greatest to the least. 这将返回范围,从最大到最小排序。 Now you simply have to get the index of your current score with the match function. 现在,您只需使用match函数获取当前分数的索引。

=MATCH(E2;UNIQUE(QUERY($A$2:$E;"select E WHERE A="&A2&" ORDER BY E DESC"));0)

This may help: 这可能会有所帮助:

=query(A:D,"Select A,B,sum(D) group by A,B order by A,sum(D) desc")

This doesn't RANK,but SORTs the SUM in the descending order. 这不是RANK,而是按降序对SUM排序。

Rank the selection against a filtered range. 根据过滤范围对选择进行排名。 Example: 例:

=Rank(C2,Filter(C$2:$C$71,F$2:$F$71=F2),1) =等级(C2,过滤器(C $ 2:$ C $ 71,F $ 2:$ F $ 71 = F2),1)

This would rank the value in c2 only if the values in f2:f72 are equal to the value in f2 (this rankes the lowest values with the lowest rank 仅当f2:f72中的值等于f2中的值时,才会对c2中的值进行排名(这将以最低的排名对最低的值进行排名

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

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