donkey shrek
New Member
- Joined
- Nov 15, 2022
- Messages
- 26
- Office Version
- 365
- Platform
- Windows
I have a column that contains lists of dates. How do I remove dates from those lists where value does not = x?
How do I specify it to remove dates where not = to specific date?The second argument toRemoveItems
is a list of the items you want removed, so just supply any date/times you want removed there.
This is my current code. Time contains lists of DateTimes. I want to remove values in those lists that contain [Start Date] - a Date valueAh, I think I misunderstood. You probably wantList.Select
instead so you can specify the criteria for the ones you want to keep.
= Table.TransformColumns(#"Removed Columns1", Time, each List.Select([Time], each _ contains [Start Date]))
=Table.FromRecords(Table.TransformRows(#"Removed Columns1", (row) => Record.TransformFields(row, {"Time", each List.Select(_, (d) => DateTime.Date(d) <> row[Start Date])})))
List.Select([Time], each DateTime.Date(_) <> [Start Date]))
Thank you! Just changed it abit and it works, this is my final code:I'm sure it is possible with TransformColumns (getting the reference to each row's [Start Date] field eludes me at the moment) but you could use something like this:
Power Query:=Table.FromRecords(Table.TransformRows(#"Removed Columns1", (row) => Record.TransformFields(row, {"Time", each List.Select(_, (d) => DateTime.Date(d) <> row[Start Date])})))
Or add a column using something like
Power Query:List.Select([Time], each DateTime.Date(_) <> [Start Date]))
and then remove the original.
= Table.AddColumn(Custom1, "Custom", each let SD = [Start Date] in List.Select([Time], each DateTime.Date(_) = SD))