When used in combination with "each" in the second argument, Table.ReplaceValue kills all existing column types (sets them back to any). Please fix: https://social.technet.microsoft.com/Forums/en...
asarraf21
7 years agoFrequent Visitor
ImkeFI got into the same problem and I solved it by using this function that I found here:
Say you have a function called revert_column_types defined as below:
(baseTable as table, processedTable as table) =>
let
baseTableType = Value.Type(baseTable),
CommonColumnNames = List.Intersect({Table.ColumnNames(baseTable), Table.ColumnNames(processedTable)}),
processedTableNewColumnTypes =
List.Transform(
CommonColumnNames,
each {_} & {Type.TableColumn(baseTableType, _)}
),
appliedColumnTypes = Table.TransformColumnTypes(processedTable, processedTableNewColumnTypes)
in
appliedColumnTypesNow in your code you can do this:
// let's assume old_table is the original table with all the right column types // now you do some crazy things like new_table = Table.ReplaceValue(old_table, ...) // all you need to do after is to call that function above result = revert_column_types(old_table, new_table)
I arrived at this solution after a day of trial/error and that finally worked for me. Hope it helps, too.