let
Source = (InputQuery as table,QueryName as text, KeyColumn as text) => let
Source = InputQuery,
#"Added Query Name"= Table.AddColumn(Source, "Query", each QueryName),
#"Kept Records Errors" = Table.SelectRowsWithErrors(#"Added Query Name",Table.ColumnNames(Source)),
#"Marked Key Column" = Table.RenameColumns( #"Kept Records Errors",{{KeyColumn, "KeyColumn"}}),
#"Transformed Row as Record" = Table.AddColumn(#"Marked Key Column", "CurrentRow", each _),
#"Transformed Row Record as Table" = Table.AddColumn(#"Transformed Row as Record", "RECORD TO TABLE", each Record.ToTable([CurrentRow])),
#"Expanded Table" = Table.ExpandTableColumn(#"Transformed Row Record as Table", "RECORD TO TABLE", {"Name", "Value"}, {"Name", "Value"}),
#"Kept Columns with Error" = Table.SelectRowsWithErrors(#"Expanded Table", {"Value"}),
#"Added Check Errors" = Table.AddColumn(#"Kept Columns with Error", "Check Errors", each try [Value]),
#"Expanded Check Errors" = Table.ExpandRecordColumn(#"Added Check Errors", "Check Errors", {"Error"}, {"Error"}),
#"Expanded Error" = Table.ExpandRecordColumn(#"Expanded Check Errors", "Error", {"Reason", "Message", "Detail"}, {"Error.Reason", "Error.Message", "Error.Detail"}),
#"Removed Other Columns" = Table.SelectColumns(#"Expanded Error",{"KeyColumn", "Query", "Name", "Error.Reason", "Error.Message", "Error.Detail"})
in
#"Removed Other Columns"
in
Source
No comments:
Post a Comment