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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

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
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors