Forum Discussion
Reconciliation
What's the point of the Date column? Is there a dependency?
- Omid_Motamedise1 year agoSuper User
No, at this stage it is not important, but at the next level I want to add the limitation for time frame, for example the transaction with difference less than 15 days can be matched.
- lbendlin1 year agoSuper User
First step: find all allowed combinations on either side. Here's the sample code for the Bank table (five items). For later reference to the values an index column is added as a convenience (not strictly required)
Bank table
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcjJU0lEyNNM3MNU3MjAyAXEMlGJ1gBJGQLaRCZKECVTCGCRhgSRhBpUAsY0NsUiYgnTrG5jBrTBRio0FAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, Date = _t, Value = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Value", Currency.Type}, {"Date", type date}},"en-GB"), #"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 0, 1, Int64.Type) in #"Added Index"Combine function to find and deduplicate combinations
(tablea,listb)=> let Next = Table.AddColumn(tablea,"id",each listb), #"Expanded id" = Table.ExpandListColumn(Next, "id"), #"Replaced Value1" = Table.ReplaceValue(#"Expanded id",each [ID],each List.Sort(List.Distinct([ID] & {[id]})),Replacer.ReplaceValue,{"ID"}) in Table.Distinct(Table.SelectColumns(#"Replaced Value1",{"ID"}))Final result for combinations of five items based on the Bank table
let Source = List.Accumulate({1..Table.RowCount(Bank)-1},Table.FromList(List.Split(Bank[Index],1), Splitter.SplitByNothing(), {"ID"}),(state,current)=>Combine(state,Bank[Index])), #"Extracted Values" = Table.TransformColumns(Source, {"ID", each Text.Combine(List.Transform(_, Text.From), ","), type text}) in #"Extracted Values"Then you can lookup the sum value for all these combinations, repeat the process for the seven items of the Financials table, and the do yet another cartesian to match the sums.
- Omid_Motamedise1 year agoSuper User
Thank you for the solution.
It does work (of course we need another column equal to the total values of the combination), but for the case facing many rows, it is too time-consuming.
Imaging the case of 100 rows (which is not too much) in the bank table, the combinations are too much.
Do you think it is possible to increase the efficency in another way?