【问题标题】:INDEX formula in Excel, Top 10, repeats previous valueExcel 中的 INDEX 公式,前 10 名,重复上一个值
【发布时间】:2020-10-29 09:34:36
【问题描述】:

我正在查看包含前 10 个值的数据的表格。我是用公式来做的:

=LARGE($R$2:$R$26,U13)

此公式位于V 列中。

这些值取自该表:

W 列中,我试图确定哪个国家/地区具有前 10 个值之一。我是用公式来做的:

=INDEX($I$2:$I$26,MATCH(V13,$R$2:$R$26,0))

我的问题如下。如果 2 个国家/地区的前十个值相同(如表底部的情况 9 和 10,其中 2 个国家/地区的值为 39),我的 INDEX 公式将重复在两行中找到的第一个国家/地区。

例如,应该有排名第 10 的尼日利亚,因为它的值也为 39。

我想,我做错了什么,是吗?

【问题讨论】:

  • 给他们不同的等级?
  • @SJR 抱歉,我不太明白。我已经编辑了我的帖子,希望现在更容易理解排名值的来源。
  • 如果您有排名所依据的数据,您可以计算唯一排名。

标签: excel excel-formula formula excel-2016


【解决方案1】:

在单元格 W4 中试试这个公式:

=IF(V3=V4,INDEX(INDIRECT("I"&MATCH(W3,I:I,0)+1&":I26"),MATCH(V4,INDIRECT("R"&MATCH(W3,I:I,0)+1&":R26"),0)),INDEX($I$2:$I$26,MATCH(V4,$R$2:$R$26,0)))

该公式检查前一个国家/地区的得分是否与实际国家相同。在这种情况下,它会在列表中搜索前一个国家并重新定义要搜索分数的范围。这样,即使是整个列表中的完美平局也会产生一个独特的国家/地区列表。

您的公式没有解决您的问题,因为 INDEX 函数会搜索所搜索值的第一次出现。它不考虑是否在另一个单元格中已经运行了另一个 INDEX。通过根据先前的结果重新定义要搜索的范围,您将只删除您正在搜索的值的第一次(或第二次、第三次或其他)出现(以及您不关心的其他一些值)。

分解我们得到的公式:

=IF(V3=V4,                                    'Checks for a tie
    '---------------------------------------------If it's a tie
    INDEX(                                       'Use a index function to pick the result
          INDIRECT(                                 'Use an indirect function to define the range to be searched
                   "I"&                                'State the column of the range to be searched
                   MATCH(W3,I:I,0)+1&                  'Use a match function to find the previous occurence of the score whithin the column of the range to be searched and add 1 to it to cut out that value (and any previous one)
                   ":I26"                              'State the closing cell of the range to be searched
                  ),
          MATCH(                                    'Use a match function to determine in what row of the defined range the score is occuring
                V4,                                    'The value to be searched
                INDIRECT(                              'Use an indirect function to define the range to be searched
                         "R"&                             'State the column of the range to be searched
                         MATCH(W3,I:I,0)+1&               'Use a match function to find the previous occurence of the score whithin the column of the range to be searched and add 1 to it to cut out that value (and any previous one)
                         ":R26"                           'State the closing cell of the range to be searched
                        ),
                0                                         'Specify that you want the the exact occurence
               )
         ),
    '---------------------------------------------If it's not a tie
    INDEX(                                       'Use a index function to pick the result
          $I$2:$I$26,                               'State the range to be searched
          MATCH(                                    'Use a match function to determine in what row of the range the score is occuring
                V4,                                    'The value to be searched
                $R$2:$R$26,                            'State the range to be searched
                0                                      'Specify that you want the the exact occurence
               )
         )

   )

【讨论】:

  • 啊啊啊!!!我们中间的魔术师!!!非常感谢您给我的最清晰的解释!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-01-12
  • 1970-01-01
  • 2011-02-06
相关资源
最近更新 更多