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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
igoto
New Member

Please help : type mismatch

I get the following error message when editing a query in Power BI.

"A type mismatch has been detected."

I don't know where in the table is the type mismatch.

Is there any way to find out where it should be fixed?

----------------------------------------------------------------

= 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 value type does not match the column type." , Detail = v], fieldTypes{i}})
in
Table.TransformColumns(source, pairs)

---------------------------------------------------------


Translated with www.DeepL.com/Translator (free version)

2 REPLIES 2
Anonymous
Not applicable

Hi @igoto ,

 

What is your data source? I think it may be a data type error, you can try to format all the columns as text, then change the data type one by one, and check which column causes this error.

 

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

lbendlin
Super User
Super User

what is behind "source" ?

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.