ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   New Users to Excel (https://www.excelbanter.com/new-users-excel/)
-   -   Filter data based on multiple columns (https://www.excelbanter.com/new-users-excel/85370-filter-data-based-multiple-columns.html)

[email protected]

Filter data based on multiple columns
 
I would like to see the unique values from column A, where Column B is
a max() for that value in A. For example, in Column A there are
several 1's, I would like to see the max of column B, where column A is
a 1, and the same thing repeated for all the other unique values in
column A.

INPUT:

A B
1 07/22/05
1 08/26/05
1 10/11/05
2 11/04/05
2 01/04/06
2 07/22/05
3 08/26/05
4 10/11/05
4 11/04/05

The output I'm looking for would look like this:

A B
1 10/11/05
2 01/04/06
3 08/26/05
4 11/04/05


Ron Coderre

Filter data based on multiple columns
 
Try a Pivot Table:

First, make sure your table has column headings
(exampe: A1: MyNumber, B1: MyDate)

<Data<Pivot Table
Use: Excel
Select your data range
Click the [Layout] button

ROW: Drag the MyNumber field here
DATA: Drag the MyDate field here
Dbl-click it and set it to Max
Click [OK]
Select where you want the Pivot Table...and you're done!

That will list each MyNumber and the Max of dates for each MyNumber.

Does that help?

***********
Regards,
Ron

XL2002, WinXP-Pro


" wrote:

I would like to see the unique values from column A, where Column B is
a max() for that value in A. For example, in Column A there are
several 1's, I would like to see the max of column B, where column A is
a 1, and the same thing repeated for all the other unique values in
column A.

INPUT:

A B
1 07/22/05
1 08/26/05
1 10/11/05
2 11/04/05
2 01/04/06
2 07/22/05
3 08/26/05
4 10/11/05
4 11/04/05

The output I'm looking for would look like this:

A B
1 10/11/05
2 01/04/06
3 08/26/05
4 11/04/05



[email protected]

Filter data based on multiple columns
 
Yea, that worked, but now here's the next problem...I have about 20
columns after the first two columns, that I will also need to display
for that combination of column A&B. How can I do this with a
pivottable?


Ron Coderre

Filter data based on multiple columns
 
See if this array formula* approach works for you:

Assumptions:
Your data table is in A1:V10
MyNumber, MyDate, MyField_1, MyField_2.....MyField_20


Your pivot table begins in cell A20 and extends through B?? (depending on
returned values)

So...A20: Max of MyNumber
A21: MyNumber
B21: Total

C21: MyField_1
C22:
=INDEX($C$1:$C$10,MATCH($A22&"_"&TEXT($B22,"yyyymm dd"),$A$1:$A$10&"_"&TEXT($B$1:$B$10,"yyyymmdd"),0) )

Copy from C22 to C23 and down as far as needed
Copy the Col_C formulas to Col_D and as far to the right as needed

*Note: For array formulas, hold down [Ctrl] and [Shift] when you press
[Enter].

Those formulas return the data associated with each unique MyNumber and the
corresponding Max of MyDate for that MyNumber.

Sample returned values (with my test data):
Max of MyDate
MyNumber_____Total____Field_1__Field_2_____Field_3
1_________10/11/05_c101_______c101_______c101
2_________01/04/06_c10001_____c10001_____c10001
3_________08/26/05_c1000001___c1000001___c1000001
4_________11/04/05_c100000001_c100000001_c100000001

Is that something you can work with?

***********
Regards,
Ron

XL2002, WinXP-Pro


" wrote:

Yea, that worked, but now here's the next problem...I have about 20
columns after the first two columns, that I will also need to display
for that combination of column A&B. How can I do this with a
pivottable?



[email protected]

Filter data based on multiple columns
 
Thanks, that worked perfectly. I ended up adding in a dynamic named
range for my pivottable, then hid the sheet where the table resides. I
added a macro for the end user to update the pivottable, without them
needing to know that it was even there. For the arrays, I added a
dynamic named range for each of my columns, so that they would update
accordingly when new rows are added.



All times are GMT +1. The time now is 01:28 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com