Forum Discussion
Modifing data based on a correction table
- 4 years ago
Hi DanFromMontreal ,
Please try the following code:
let #"Unpivot tblData" = Table.UnpivotOtherColumns(tblData, {"RowID"}, "Attribute", "Value"), #"Unpivot tblCorrection" = Table.UnpivotOtherColumns(tblCorrection, {"RowID"}, "Attribute", "Value"), Source = Table.NestedJoin(#"Unpivot tblData", {"RowID", "Attribute"}, #"Unpivot tblCorrection", {"RowID", "Attribute"}, "tblCorrection", JoinKind.LeftOuter), #"Expanded tblCorrection" = Table.ExpandTableColumn(Source, "tblCorrection", {"Value"}, {"tblCorrection.Value"}), #"Added Custom" = Table.AddColumn(#"Expanded tblCorrection", "Custom", each if [tblCorrection.Value] = " " or [tblCorrection.Value] = null then [Value] else [tblCorrection.Value]), #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Value", "tblCorrection.Value"}), #"Pivoted Column" = Table.Pivot(#"Removed Columns", List.Distinct(#"Removed Columns"[Attribute]), "Attribute", "Custom") in #"Pivoted Column"If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
this should be faster.
if you publish tables with fake data but with the size and structure of your tables, one can do some tests to find the best performing solution.
PS
The "optimal" strategy obviously depends on the size of the tables.
From how many columns and how many rows the tables typically have it derives whether it is convenient to make the transformations by rows or by columns, whether to merge or do lookups, etc ...