Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
Hi All,
I have this code below. I am not sure how to get rid of the Errors.
I want all (Blank) to just say Blank and null to say N/A
let
Source = #"FACT TABLE",
#"Detected Type Mismatches" = let
tableWithOnlyPrimitiveTypes = Table.SelectColumns(Source, Table.ColumnsOfType(Source, {type nullable number, type nullable text, type nullable logical, type nullable date, type nullable datetime, type nullable datetimezone, type nullable time, type nullable duration})),
recordTypeFields = Type.RecordFields(Type.TableRow(Value.Type(tableWithOnlyPrimitiveTypes))),
fieldNames = Record.FieldNames(recordTypeFields),
fieldTypes = List.Transform(Record.ToList(recordTypeFields), each [Type]),
pairs = List.Transform(List.Positions(fieldNames), (i) => {fieldNames{i}, (v) => if v = null or Value.Is(v, fieldTypes{i}) then v else error [Message = "The type of the value does not match the type of the column.", Detail = v], fieldTypes{i}})
in
Table.TransformColumns(Source, pairs),
#"Added Index" = Table.AddIndexColumn(#"Detected Type Mismatches", "Row Number" ,1),
#"Kept Errors" = Table.SelectRowsWithErrors(#"Added Index", {"Source.Name", "SDR ID", "Site", "Card number", "CP ID", "Connector", "Charger Type", "Amount", "Consum(kWh)", "Duration", "Start Date", "Start Time", "End Date", "End Time", "Payment Status", "Start Hour", "Payment Method"}),
#"Reordered Columns" = Table.ReorderColumns(#"Kept Errors", {"Row Number", "Source.Name", "SDR ID", "Site", "Card number", "CP ID", "Connector", "Charger Type", "Amount", "Consum(kWh)", "Duration", "Start Date", "Start Time", "End Date", "End Time", "Payment Status", "Start Hour", "Payment Method"})
I highly appreciate any help with this.
Thank you,
jiCAT
in
#"Reordered Columns"
Solved! Go to Solution.
Hello - it looks like the script you are showing here is for the errors table that Power Query creates instead of the actual data table with th errors. Below is how you can replace blanks with Blank and nulls with N/A. You will need to do this on the actual data table.
Replace Blanks:
Replace Nulls:
Hello - it looks like the script you are showing here is for the errors table that Power Query creates instead of the actual data table with th errors. Below is how you can replace blanks with Blank and nulls with N/A. You will need to do this on the actual data table.
Replace Blanks:
Replace Nulls:
Thank you @jennratten,
It worked magic. I must remember to use the simplest solution first.
Much appreciate your help.
Best,
jiCAT