Power Query - Pull Over Latest Date From Another Column

lager1001

New Member
Joined
May 17, 2019
Messages
19
This would seemingly be simple to do. I have a "Report Date"column with hundreds of rows of dates. I need a custom column that indicates with an "x" or a flag of some type if each row in the Report Date column contains the latest report date within the column itself. Not today's date but the latest date found in the column. I can do this in Excel but run into trouble trying to write it in power query. Any ideas?

OrderReport DateLatest Date
1212310/10/2019
1212310/11/2019
1212310/14/2019
1212310/15/2019
1212310/17/2019
1212310/18/2019
1212310/21/2019
1212310/22/2019x
1244410/10/2019
1244410/11/2019
1244410/14/2019
1244410/15/2019
1244410/17/2019
1555510/10/2019
1555510/11/2019
1555510/14/2019
3232310/10/2019
3232310/11/2019
3232310/14/2019
3232310/15/2019
3232310/17/2019
3232310/18/2019
3232310/21/2019
3232310/22/2019x

<colgroup><col><col><col></colgroup><tbody>
</tbody>
 

sandy666

Well-known Member
Joined
Oct 24, 2015
Messages
3,820
you can try with Group and Max from Report Date
or
Table.Max from Report Date

but this is not an Excel worksheet way
 
Last edited:

sandy666

Well-known Member
Joined
Oct 24, 2015
Messages
3,820
is this acceptable?

OrderReport DateLatest Date
12123​
10/10/2019​
12123​
11/10/2019​
12127​
14/10/2019​
12123​
15/10/2019​
12123​
17/10/2019​
12123​
18/10/2019​
12123​
21/10/2019​
12123​
22/10/2019​
22/10/2019​
12444​
10/10/2019​
12444​
11/10/2019​
12444​
14/10/2019​
12444​
15/10/2019​
12444​
17/10/2019​
15555​
10/10/2019​
15555​
11/10/2019​
15555​
14/10/2019​
32323​
10/10/2019​
32323​
11/10/2019​
32323​
14/10/2019​
32323​
15/10/2019​
32323​
17/10/2019​
32323​
18/10/2019​
32323​
21/10/2019​
32323​
22/10/2019​
22/10/2019​

Code:
[SIZE=1]// TableMaxDate
let
    Source = Excel.CurrentWorkbook(){[Name="[I][COLOR="#FF0000"]YourTableName[/COLOR][/I]"]}[Content],
    Tmax = Table.PromoteHeaders(Table.SelectColumns(Table.Transpose(Record.ToTable(Table.Max(Source,"Report Date"))),{"Column2"}), [PromoteAllScalars=true]),
    Merge = Table.NestedJoin(Source,{"Report Date"},Table.RenameColumns(Tmax,{{"Report Date", "Latest Date"}}),{"Latest Date"},"Latest Date",JoinKind.LeftOuter),
    Type = Table.TransformColumnTypes(Table.ExpandTableColumn(Merge, "Latest Date", {"Latest Date"}, {"Latest Date"}),{{"Report Date", type date}, {"Latest Date", type date}})
in
    Type[/SIZE]
 

sandy666

Well-known Member
Joined
Oct 24, 2015
Messages
3,820
or even this

Code:
[SIZE=1]// TableMaxDate
let
    Source = Excel.CurrentWorkbook(){[Name="[I][COLOR="#FF0000"]YourTableName[/COLOR][/I]"]}[Content],
    TMax = Table.PromoteHeaders(Table.SelectColumns(Table.Transpose(Record.ToTable(Table.Max(Source,"Report Date"))),{"Column2"}), [PromoteAllScalars=true]),
    Result = Table.ExpandTableColumn(Table.NestedJoin(Source,{"Report Date"},TMax,{"Report Date"},"Latest Date",JoinKind.LeftOuter), "Latest Date", {"Report Date"}, {"Latest Date"}),
    Type = Table.TransformColumnTypes(Result,{{"Report Date", type date}, {"Latest Date", type date}})
in
    Type[/SIZE]
 

Forum statistics

Threads
1,082,297
Messages
5,364,372
Members
400,793
Latest member
hamzayagiz

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