Find [Field2] value associated with Max[Date]

horseyride

Board Regular
Joined
Nov 2, 2017
Messages
82
I want to find Text1 associated with Max[Date] (here "cat") and use that to create column Text2 for any matching Text1's

<table>
<tr><td>Date</td><td>Text1</td></tr>
<tr><td>11/1/2017</td><td>dog</td></tr>
<tr><td>11/2/2017</td><td>cat</td></tr>
<tr><td>11/3/2017</td><td>rat</td></tr>
<tr><td>11/7/2017</td><td>dog</td></tr>
<tr><td>11/8/2017</td><td>cat</td></tr>
</table>

Results in:

<table>
<tr><td>Date</td><td>Text1</td><td>Text2</td></tr>
<tr><td>11/1/2017</td><td>dog</td><td>No</tr>
<tr><td>11/2/2017</td><td>cat</td><td>Yes</tr>
<tr><td>11/3/2017</td><td>rat</td><td>No</tr>
<tr><td>11/7/2017</td><td>dog</td><td>No</tr>
<tr><td>11/8/2017</td><td>cat</td><td>Yes</tr>
</table>

I can find the max date List.Max(#"Expanded"[Date]) but can't figure out how to grab the Text1 field
#"Added Custom" = Table.AddColumn(#"Expanded", "Text2", each if [Date]<= (List.Max(#"Expanded"[Date]) then "YES" else "No"),

Thanks
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
You can use Table.Max, which will give you a record with all fields from the table of the row with the maximum date.
One remark: if you have multiple max dates, you will only get 1 result.

Code:
let
    Source = Table1,
    #"Added Custom" = Table.AddColumn(Source, "Text2", each if [Text1] = Table.Max(Source, "Date")[Text1] then "Yes" else "Mo")
in
    #"Added Custom"
 
Upvote 0

Forum statistics

Threads
1,223,248
Messages
6,171,027
Members
452,374
Latest member
keccles

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top