根据唯一值获取最大值 [英] Get maximum value based on unique values

查看:200
本文介绍了根据唯一值获取最大值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Excel中有两列,如下所示:

I have two columns in Excel as follows:

col1  col2

1     10
1     22
1     11
1     23
1     14
2     16
2     12
2     10
2     9

如何编写命令从 col2 对应于 col1 中的每个唯一值?

How do I write a command to returns the maximum value from col2 corresponding to each unique value in col1?

所以这里我需要写一个命令来获取 23 16

So here I need to write a command to get 23 and 16.

我在这里显示的数据是虚拟的;我的实际数据集中的 col1 中有600个唯一值。

The data I have shown here are dummies; I have 600 unique values in col1 in my actual data set.

推荐答案

数据透视表:excel最不充分和最强大的功能。

Pivot tables: the single most underutilized and powerful feature of excel.


  • 文件菜单:

  • 插入

  • 数据透视表

  • 选择范围

  • 如下图所示填写

  • File menu:
  • Insert
  • Pivot Table
  • Select range
  • Fill in as indicated in image below

一步一步:


  • 将光标放在表格上所有数据右侧的单元格中。

  • 从菜单中选择插入

  • 选择数据透视表图标

  • 从弹出图标中选择数据透视表

  • 使用按钮选择包含的单元格范围(所有600行的两列)(或只输入$ A:$ B)

  • 选择ok

  • 右侧显示一个数据透视表字段列表:

  • 将行1拖放到行标签中。

  • 将行2拖放到值区域中。

  • 左键单击...第2行

  • 选择值字段设置

  • 选择选择确定,然后选择确定,然后选择您想要的结果。

  • Place cursor in cell to right of all data on sheet.
  • Select insert from menu
  • select pivot table icon
  • select pivot table from pop-up of icon
  • use the button to select the range of cells included (all 600+ rows in 2 columns) (or just enter $A:$B)
  • select ok
  • A pivot table field list appears on the right:
  • Drag and drop row 1 into row labels.
  • drag and drop row 2 into values area.
  • left click on "... of Row 2"
  • select value field settings
  • select "Max" instead of count or sum
  • select ok and you should have desired results.

数据透视表将在第1行中为每个唯一值找到第2行中的最大值,这是我以前相信的。

The pivot table will find the max value in row 2 for each unique value in row 1 which is what I believe you are after.

这篇关于根据唯一值获取最大值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆