Filter a list to only return top 2 most recent results?

CamelDCamel

New Member
Joined
Nov 11, 2019
Messages
1
Hi All,

I'm new here, so firstly nice to meet you all!

Trying to work out a way to approach this situation. I have a set of data similar to the following. What I want to do is find a way to only show the 2 most latest (most recent date) for each User. For example:

DateNameValue
01/01/19User 117
02/03/19User 14
13/04/19User 112
01/01/19User 25
02/03/19User 223
13/04/19User 22
18/05/19User 244
01/01/19User 312
02/03/19User 346
01/01/19User 411
02/03/19User 462
13/04/19User 421
18/05/19User 44
01/01/19User 52
02/03/19User 561
13/04/19User 533
18/05/19User 511
20/06/19User 534

<tbody>
</tbody>

As an end result, I was trying to get something like this:

DateNameValue
2/03/19User 14
13/04/19

<tbody>
</tbody>
User 112
13/04/19

<tbody>
</tbody>
User 22
18/05/19

<tbody>
</tbody>
User 244
1/01/19

<tbody>
</tbody>
User 312
2/03/19

<tbody>
</tbody>
User 346
13/04/19

<tbody>
</tbody>
User 421
18/05/19

<tbody>
</tbody>
User 44
18/05/19

<tbody>
</tbody>
User 531
20/06/19

<tbody>
</tbody>
User 534

<tbody>
</tbody>

I thought about putting the data in a pivot table, then sorting the pivot table so the most recent date is always leftmost, then having another sheet that gets the 2 leftmost values with data, however I feel that's probably quite convoluted and there is an easy way.

The data is transnational and will continue to change daily but I only way the last 3 days for each user.

Does anyone have any suggestions on how to approach this?

Thanks in advance!
 

DRSteele

Well-known Member
Joined
Mar 31, 2015
Messages
2,048
Office Version
365
Platform
Windows
Welcome to the forum.

This might help you. Copy the A22 and C22 formulas downwards. You will have to populate the B column with the text two of each User. You can hide the helper column with the 2's and the 1's if you like. This will only work if there are no duplicates.

[FONT=Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif]<b></b><table cellpadding="2.5px" rules="all" style=";background-color: rgb(255,255,255);border: 1px solid;border-collapse: collapse; border-color: rgb(187,187,187)"><colgroup><col width="25px" style="background-color: rgb(218,231,245)" /><col /><col /><col /><col /></colgroup><thead><tr style=" background-color: rgb(218,231,245);text-align: center;color: rgb(22,17,32)"><th></th><th>A</th><th>B</th><th>C</th><th>D</th></tr></thead><tbody><tr ><td style="color: rgb(22,17,32);text-align: center;">1</td><td style="background-color: #FFF2CC;;">Date</td><td style="background-color: #FFF2CC;;">Name</td><td style="background-color: #FFF2CC;;">Value</td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">2</td><td style="text-align: right;;">1/1/2019</td><td style=";">User 1</td><td style="text-align: right;;">17</td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">3</td><td style="text-align: right;;">3/2/2019</td><td style=";">User 1</td><td style="text-align: right;;">4</td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">4</td><td style="text-align: right;;">4/13/2019</td><td style=";">User 1</td><td style="text-align: right;;">12</td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">5</td><td style="text-align: right;;">1/1/2019</td><td style=";">User 2</td><td style="text-align: right;;">5</td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">6</td><td style="text-align: right;;">3/2/2019</td><td style=";">User 2</td><td style="text-align: right;;">23</td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">7</td><td style="text-align: right;;">4/13/2019</td><td style=";">User 2</td><td style="text-align: right;;">2</td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">8</td><td style="text-align: right;;">5/18/2019</td><td style=";">User 2</td><td style="text-align: right;;">44</td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">9</td><td style="text-align: right;;">1/1/2019</td><td style=";">User 3</td><td style="text-align: right;;">12</td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">10</td><td style="text-align: right;;">3/2/2019</td><td style=";">User 3</td><td style="text-align: right;;">46</td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">11</td><td style="text-align: right;;">1/1/2019</td><td style=";">User 4</td><td style="text-align: right;;">11</td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">12</td><td style="text-align: right;;">3/2/2019</td><td style=";">User 4</td><td style="text-align: right;;">62</td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">13</td><td style="text-align: right;;">4/13/2019</td><td style=";">User 4</td><td style="text-align: right;;">21</td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">14</td><td style="text-align: right;;">5/18/2019</td><td style=";">User 4</td><td style="text-align: right;;">4</td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">15</td><td style="text-align: right;;">1/1/2019</td><td style=";">User 5</td><td style="text-align: right;;">2</td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">16</td><td style="text-align: right;;">3/2/2019</td><td style=";">User 5</td><td style="text-align: right;;">61</td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">17</td><td style="text-align: right;;">4/13/2019</td><td style=";">User 5</td><td style="text-align: right;;">33</td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">18</td><td style="text-align: right;;">5/18/2019</td><td style=";">User 5</td><td style="text-align: right;;">11</td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">19</td><td style="text-align: right;;">6/20/2019</td><td style=";">User 5</td><td style="text-align: right;;">34</td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">20</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">21</td><td style="background-color: #FCE4D6;;">Date</td><td style="background-color: #FCE4D6;;">Name</td><td style="background-color: #FCE4D6;;">Value</td><td style="background-color: #FCE4D6;;">Recent</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">22</td><td style="text-align: right;background-color: #E2EFDA;;">3/2/2019</td><td style=";">User 1</td><td style="text-align: right;background-color: #C6E0B4;;">4</td><td style="text-align: right;;">2</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">23</td><td style="text-align: right;background-color: #E2EFDA;;">4/13/2019</td><td style=";">User 1</td><td style="text-align: right;background-color: #C6E0B4;;">12</td><td style="text-align: right;;">1</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">24</td><td style="text-align: right;background-color: #E2EFDA;;">4/13/2019</td><td style=";">User 2</td><td style="text-align: right;background-color: #C6E0B4;;">2</td><td style="text-align: right;;">2</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">25</td><td style="text-align: right;background-color: #E2EFDA;;">5/18/2019</td><td style=";">User 2</td><td style="text-align: right;background-color: #C6E0B4;;">44</td><td style="text-align: right;;">1</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">26</td><td style="text-align: right;background-color: #E2EFDA;;">1/1/2019</td><td style=";">User 3</td><td style="text-align: right;background-color: #C6E0B4;;">12</td><td style="text-align: right;;">2</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">27</td><td style="text-align: right;background-color: #E2EFDA;;">3/2/2019</td><td style=";">User 3</td><td style="text-align: right;background-color: #C6E0B4;;">46</td><td style="text-align: right;;">1</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">28</td><td style="text-align: right;background-color: #E2EFDA;;">4/13/2019</td><td style=";">User 4</td><td style="text-align: right;background-color: #C6E0B4;;">21</td><td style="text-align: right;;">2</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">29</td><td style="text-align: right;background-color: #E2EFDA;;">5/18/2019</td><td style=";">User 4</td><td style="text-align: right;background-color: #C6E0B4;;">4</td><td style="text-align: right;;">1</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">30</td><td style="text-align: right;background-color: #E2EFDA;;">5/18/2019</td><td style=";">User 5</td><td style="text-align: right;background-color: #C6E0B4;;">11</td><td style="text-align: right;;">2</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">31</td><td style="text-align: right;background-color: #E2EFDA;;">6/20/2019</td><td style=";">User 5</td><td style="text-align: right;background-color: #C6E0B4;;">34</td><td style="text-align: right;;">1</td></tr></tbody></table><p style="width:5.6em;font-weight:bold;margin:0;padding:0.2em 0.6em 0.2em 0.5em;border: 1px solid rgb(187,187,187);border-top:none;text-align: center;background-color: rgb(218,231,245);color: rgb(22,17,32)">Sheet47</p><br /><br /><table width="85%" cellpadding="2.5px" rules="all" style=";border: 2px solid black;border-collapse:collapse;padding: 0.4em;background-color: rgb(255,255,255)" ><tr><td style="padding:6px" ><b>Worksheet Formulas</b><table cellpadding="2.5px" width="100%" rules="all" style="border: 1px solid;text-align:center;background-color: rgb(255,255,255);border-collapse: collapse; border-color: rgb(187,187,187)"><thead><tr style=" background-color: rgb(218,231,245);color: rgb(22,17,32)"><th width="10px">Cell</th><th style="text-align:left;padding-left:5px;">Formula</th></tr></thead><tbody><tr><th width="10px" style=" background-color: rgb(218,231,245);color: rgb(22,17,32)">A22</th><td style="text-align:left">=LARGE(<font color="Blue">(<font color="Red">$A$2:$A$19</font>)*(<font color="Red">$B$2:$B$19=B22</font>),D22</font>)</td></tr><tr><th width="10px" style=" background-color: rgb(218,231,245);color: rgb(22,17,32)">C22</th><td style="text-align:left">=INDEX(<font color="Blue">$C$2:$C$19,MATCH(<font color="Red">A22&B22,$A$2:$A$19&$B$2:$B$19,0</font>)</font>)</td></tr></tbody></table></td></tr></table><br />[/FONT]
 

Forum statistics

Threads
1,082,017
Messages
5,362,695
Members
400,686
Latest member
Aakash

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top