The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
let
Source = TM1_Static_Budget_FY2024,
#"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", {"AssetID", "Country", "Region/Segment", "Location", "Project", "Asset Type", "Asset Description", "MonthOfYear", "TotalBudget", "MonthInNumbers", "Month/Quarter", "MonthDate"}),
#"Reordered Columns" = Table.ReorderColumns(#"Kept Errors", {"Row Number", "AssetID", "Country", "Region/Segment", "Location", "Project", "Asset Type", "Asset Description", "MonthOfYear", "TotalBudget", "MonthInNumbers", "Month/Quarter", "MonthDate"})
in
#"Reordered Columns"
What is your question?