Forum Discussion

Moh_Ashraf's avatar
Moh_Ashraf
Frequent Visitor
1 year ago
Solved

How to make select a format for column containing numbers or text?

I have a column contains sometime numbers and other times text, it make error "Data format error, we couldn't convert to number". i.e:  Cell 1 > 83 Cell 2 > Open
  • BA_Pete's avatar
    BA_Pete
    1 year ago

     

    You need to make sure you're making the type conversion BEFORE any other conversions take place. It looks like you probably have 'Automatically detect data types' enabled and Power Query has put a conversion step in for you at the start of the query steps just after the source is imported.

    Go to the top of your query steps and see if there's a Changed Types step already there. If yes, then select that step, change the type of your column to Text and, when prompted, choose to replace the step, rather than add a new one.

     

    Pete

  • BA_Pete's avatar
    BA_Pete
    1 year ago

     

    Perfect. Glad that worked for you.

    As an aside: Do NOT use Type Any in Power Query. You should always change your columns to explicit data types. It doesn't have to be done at the first step that we're talking about, but you should always ensure that all of your columns have an explicit data type by the end of the query to avoid causing yourself problems when you apply the query to the data model.

     

    Pete