Forum Discussion

ksheth's avatar
ksheth
Helper I
1 year ago
Solved

OLE DB or ODBC error: [DataFormat.Error] We couldn't convert to Number..

Hello,   I am encountering the error "OLE DB or ODBC error: [DataFormat.Error] We couldn't convert to Number.." when trying to apply changes from the query editor.       I have several a...
  • AmiraBedh's avatar
    1 year ago

    I have a doubt with this part:

    {"CRace_CEth_Combined_Broad", type text}, "ComboRegionName", "Age Group"

    it may not able to correctly specify types for "ComboRegionName" and "Age Group", which might be leading Power BI to guess a default type (likely type number) for one or both columns.

    So even though you later remove these columns, the error might occur before that removal if something earlier (like column type inference or a cached schema) tries to validate the whole table before applying transforms.

    Try to modify the "Changed Type" step to properly define the types for all columns:

    #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{
    {"PIN", type text},
    {"Date", type date},
    {"Time", type time},
    {"Zipcode", Int64.Type},
    {"Age", Int64.Type},
    {"Sex", type text},
    {"Hospital", type text},
    {"CRace_CEth_Combined_Broad", type text},
    {"ComboRegionName", type text},
    {"Age Group", type text}
    }),


    I think the error only appears after deduplication likely because that’s when Power BI tries to load and materialize the data into the model.
    Deduplicating with Table.Distinct doesn’t itself coerce types but if the underlying data has unexpected values or nulls, the type transformations applied before or after could fail during the final load.

    Some improvements for your code :

     

    each if [Zipcode] = null or [Zipcode] = "" then "A" else [Zipcode]


    or better:

     

    each if [Zipcode] = null then "A" else Text.From([Zipcode])


    Or even better:

     

    each if [Zipcode] = null then "A" else [Zipcode], type text