简体   繁体   中英

Vlookup max / min of multiple results

I have a list of values in EXCEL

X   Y
5   3000
5   3200
5   2800
10  1600
10  2900
10  3500
15  1800
15  4500

I want to get the list of X without duplicates and corresponding MIN / MAX values Y. Something like this for MAX values:

X   Y
5   3200
10  3500
15  4500

How do I proceed?

A simple pivot table will do that.

  • Insert Pivot Table
  • Drag X to the rows area
  • Drag y to the Values area twice
    • Adjust value settings for one Y to MAX
    • Adjust value settings for one Y to MIN

在此处输入图像描述

Have a look at PowerQuery :

  • Select any cell within your data range.
  • Click the Data tab, then > From Table/Range .
  • If prompted, in the From Table dialog box, you can click the Range Selection button to select a specific range to use as a data source.
  • If the table or range of data has column headers, you can check My table has headers . The header cells are used to define the column names for the query.

Within PowerQuery AKA Get&TransForm

  • Click the Transform tab, then > Group by .
  • In the dialog box, click Advanced and under Group by you choose X
  • Choose a New column name , eg: maxVals . Furthermore choose Max as an Operation and under Column you choose Y .
  • Confirm through OK and close PowerQuery .

You'll now end up with your desired output. Replicate this for the minVals .

For MAX values you could sort your data: column X ascending & column Y descending and then apply an advanced filter (only to column X), checking the option for unique values only for MIN values you repeat the process but specify ascending as the sort order for column Y Recording macros of these actions will provide you with the VBA code, which you should be able to make dynamic as you are asking your question in a Lecture after the Sections on Variables and Range References.

I hope this will be helpful

Will you do this more than once or multiple times?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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