Forum Discussion
Function to update any table with new values from another table
(Deleted prvious response as I noticed that I made an error when trying to apply)
Thanks for the suggestion! Lean piece of code, but I have to admit that I have not yet fully understood it. Will try when I find the time.
Really surprised that there is no stock-function for this tasks - it seems quite common.
When traqying to apply your solution, I don't seem to get the planned result though - same as a Table.Combine except that the column sequence has changed.
I also notice that it only works with fables fully converted to text, else I get "cannot convert to text" errors.
Attributed input must be a list of column names, right (so a list from 1-5 in my eample case)?
I may be doing something wrong, though...
Thomas
Hi Thomas,
Sorry, was not clear in my post - thee attributes list assumes "group by" columns, in your case [Date]. 1-5 are "value" columns.
If you do it this way it should work Ok, in my test 1-5 has "number-type" values, everything works fine. In fact, it doe not matter what type of data is in these columns, it will be removed in any case (a code for adding the formatting back is quite simple anyway). You can even mix formats in the "old" and "new" data, in this case a number can be replaced by a text and vice versa.
This is my code for using the function (assuming it is called fUpdate😞
let
Source = fUpdateTable(DictionaryTbl, UpdateTbl, {"Date"})
in
Source
Kind regards,
John
- thowa6 years agoRegular Visitor
Anonymous
THANKS!
One table had 2020 and the other 2000 as the years...so obviously they wouldn't combine!
...I noticed that after banging my head against the wal all day!
Thanks so much for following up. Great Code piece.
Thomas
- thowa6 years agoRegular Visitor
Anonymous
Important to note: it ONLY works with this trigger code.
I used the interface and Power Query will make me chose a column from one of the Tables.
As a reasult the list of dates is handed over as Attributes parameter instead of the column name ("Date").
With that in mind: works great!
- thowa6 years agoRegular Visitor
Have posted a summary of the two solutions proposed in form of functions here:
Overlaying/merging two tables to add missing data in empty cells and new rows/columns
- DylanEvans4 years agoFrequent Visitor
Sorry to jump on a 2yo thread, but for noobs hoping to reuse this code, can you explain where to add this function? Which string refers to the tables? Which string refers to the unique column? Also: will this work as-is for merging a single table with pre-existing dupe records against itself?