Forum Discussion
Date Pairing
- 1 year ago
Hi DuncanYeah , another solution you can look at. I'll leave the image of output and M code used. Thanks!
let
Source = Excel.CurrentWorkbook(){[Name="Table5"]}[Content],
MainTable = Table.TransformColumnTypes(Source,{{"Table A", type datetime}}),
Dates = Excel.CurrentWorkbook(){[Name = "Table6"]}[Content][#"Table B "],
Match = Table.AddColumn(MainTable,"Date", each try Dates{List.PositionOf(Dates,Record.ToList(_){0})} otherwise null),
Table = Table.FillDown(Match,{"Date"})inTable
Assuming in date format
let
Source = #"Table A",
#"Merged Queries" = Table.AddColumn( Source, "x", each #"Table B"[Date] ),
#"Expanded x" = Table.ExpandListColumn(#"Merged Queries", "x"),
#"Filtered Rows" = Table.SelectRows(#"Expanded x", each ([x] < [Date]))
in
#"Filtered Rows"- DuncanYeah1 year agoHelper III
Dear Deku ,
Thx for your reply but there are error
Expression.Error: A cyclic reference was encountered during evaluation.Duncan
- Deku1 year agoSuper User
I ran it in a new table, table c. If you want it to run in table a you need to remove the
Source = #"Table A" and update #"Merged Queries" to reference the last step in your current query
- Deku1 year agoSuper User
Like this
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTwTSxSitWJVjKCs4zhLBMQSwHMNEUwzRBMcwTTAqIrFgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}}), #"Merged Queries" = Table.AddColumn( #"Changed Type", "x", each #"Table B"[Date] ), #"Expanded x" = Table.ExpandListColumn(#"Merged Queries", "x"), #"Filtered Rows" = Table.SelectRows(#"Expanded x", each ([x] < [Date])) in #"Filtered Rows"