Hi @Ian Lyons
(it would be nice of you to revise the title of this request with something that better reflects your need => could help people who search the site)
1/ Format your 2 Sets as Excel Tables and name them Table1 and Table2 for now
2/ Load each Table as a Connection only
3/ Create a new blank query with the following code:
let
Source = Table.NestedJoin(Table1, {"Client Id"}, Table2, {"Client iD"}, "DatesTable2", JoinKind.LeftOuter),
Transformed = Table.TransformColumns(Source,
{"DatesTable2", each
let
ReplacedNullEnd = Table.TransformColumns(_,
{"Date Agreement Ended", each if _ is null then Date.From(DateTime.LocalNow()) else _, type date}
),
DatesList = Table.AddColumn(ReplacedNullEnd, "Dates", each
List.Dates([Date Agreement Started], Duration.Days([Date Agreement Ended]-[Date Agreement Started])+1, #duration(1,0,0,0)),
type list
),
DistinctList = List.Union(DatesList[Dates])
in
if Table.IsEmpty(_) then {} else DistinctList,
type list
}
),
ClientStatus = Table.AddColumn(Transformed, "Client Status At time Of Request", each
if List.Contains([DatesTable2], [Date Of Request]) then "Existing Customer"
else "New Customer",
type text
),
RemovedDatesTable2 = Table.RemoveColumns(ClientStatus,{"DatesTable2"})
in
RemovedDatesTable2
This looks good to me with the data you exposed. Your file updated as described above is available here.
Any question/issue let me know & if problem solved please mark this reply as answer (can help others) - Thanks