Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Anonymous
Not applicable

Advanced Editor - Error

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"

1 ACCEPTED SOLUTION
jennratten
Super User
Super User

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.

 

  1. Select the column containing the values to be replaced.
  2. Either right-click on the column or go to the ribbon.
  3. Choose replace values.
  4. Enter the old value (don't enter anything to replace blanks, type the word null to replace nulls) and the new value (Blank or N/A).
  5. Click Okay.

Replace Blanks:

jennratten_0-1671531669115.png

 

Replace Nulls:

jennratten_1-1671531706620.png

 

View solution in original post

2 REPLIES 2
jennratten
Super User
Super User

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.

 

  1. Select the column containing the values to be replaced.
  2. Either right-click on the column or go to the ribbon.
  3. Choose replace values.
  4. Enter the old value (don't enter anything to replace blanks, type the word null to replace nulls) and the new value (Blank or N/A).
  5. Click Okay.

Replace Blanks:

jennratten_0-1671531669115.png

 

Replace Nulls:

jennratten_1-1671531706620.png

 

Anonymous
Not applicable

Thank you @jennratten, 

It worked magic. I must remember to use the simplest solution first. 
Much appreciate your help. 
Best, 
jiCAT

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors