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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
mattymc1984
Advocate I
Advocate I

columns with mixed data types

Hi,

 

I'm working with debtor/invoice data.  One of my fields is "Account Number".  Roughly 80% of these are numeric, however internal customer numbers have a letter prefixing the account number.  Power Query auto detects this column as numeric and when I load the data into Excel or PowerBI it returns all the account numbers with letters in them as errors, which I understand.  However I need to have all account numbers shown, so I tried to select data type as text, but this doesn't work either and the error report says that Power Query is still trying to convert these alpha strings into numeric.

 

Any help would be much appreciated!

 

Matt

1 ACCEPTED SOLUTION
MarcelBeug
Community Champion
Community Champion

If you add an extra step to change number back to text, the errors won't be corrected, so you should adjust the autogenerated step in which the data types were changed and adjust "number" to "text" for the Account Number field.

 

Specializing in Power Query Formula Language (M)

View solution in original post

5 REPLIES 5
MarcelBeug
Community Champion
Community Champion

If you add an extra step to change number back to text, the errors won't be corrected, so you should adjust the autogenerated step in which the data types were changed and adjust "number" to "text" for the Account Number field.

 

Specializing in Power Query Formula Language (M)

This did it thanks!

 

As you said, I went to the auto-generated steps where Power Query first decides on the data type of each field and changed the "Account" type to text.  Sorted.  Thankyou.

 

vanessafvg
Super User
Super User

when you say you tried to change it to text its still keep it as numeric it what do you mean, it should correct the problem if you change it to text, can i see your power query steps?  





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




This is the line of code for changing the data type:

 

 #"Changed Type1" = Table.TransformColumnTypes(#"Filtered Rows",{{"Account", type text}}),

 

However, when I load the data into Excel, it still returns all the alpha account numbers as errors:

 

DataFormat.Error: We couldn't convert to Number.
Details:
    A003

Refereing to my previous post: that doesn't look like the line of code with the initial type change (because the "1" in the step name and because it is referencing previous step #"Filtered Rows") .

 

My suggestion would be to delete this step and adjust the #"Changed Type" step (probably the second or third step in your code).

Specializing in Power Query Formula Language (M)

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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