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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Mischa
Frequent Visitor

Power Query - Text to Number Error

Hello! 

 

I am currently busy with loading a new Query in Power Query. 

 

However, I cannot seem to transform a text column to number 

Mischa_0-1629965930096.png

>>

Mischa_1-1629964738450.png

>>

Mischa_0-1629964658096.png

 

I have tried new column trim and then converting and this still does not work

 

please help!

 

thank you kindly 

M

 

8 REPLIES 8
LungisGran
New Member

Good Day,

I was strugglng with the same issue today and  tried a number of options which did not work.  

Use the Parse option on the Transform Tab and choose JSON.  It worked pefectly.

PC2790
Community Champion
Community Champion

Can you share some sample data and the M query from the advanced editor?

Looks like there is some record which is unchangeable and hence stopping you from changing the type.

Mischa
Frequent Visitor

Hi @PC2790 ! 

 

Thanks for trying to assist

 

I was unable to load a .xlsx or .csv file 

so heres a direct copy&paste (if this even helps) - otherwise just let me know how I can attach this

product_idproduct_brandproduct_nameproduct_skuproduct_retail_priceproduct_costproduct_weightrecyclablelow_fat
1WashingtonWashington Berry Juice9.07E+102.850.948.39  
2WashingtonWashington Mango Drink9.65E+100.740.267.42 1
3WashingtonWashington Strawberry Drink5.84E+100.830.413.111
4WashingtonWashington Cream Soda6.44E+103.641.6410.61 
5WashingtonWashington Diet Soda8.56E+102.190.776.661 
6WashingtonWashington Cola2.98E+101.150.3715.8  
7WashingtonWashington Diet Cola2.02E+102.610.91181 
8WashingtonWashington Orange Juice8.98E+102.590.88.971 
9WashingtonWashington Cranberry Juice4.94E+102.420.777.14  
10WashingtonWashington Apple Juice2.21E+101.420.58.131 

advanced editor

let
Source = Csv.Document(File.Contents("C:\Users\Mischa\Downloads\FoodMart+CSV+Files (1)\Product-Lookup.csv"),[Delimiter=",", Columns=9, Encoding=1252, QuoteStyle=QuoteStyle.None]),
#"Promoted Headers" = Table.PromoteHeaders(Source, [PromoteAllScalars=true]),
#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"product_id", Int64.Type}, {"product_brand", type text}, {"product_name", type text}, {"product_sku", Int64.Type}, {"product_retail_price", type text}, {"product_cost", type text}, {"product_weight", type text}, {"recyclable", Int64.Type}, {"low_fat", Int64.Type}})
in
#"Changed Type"

PC2790
Community Champion
Community Champion

For me it is working fine.

You can try changing it to Decimal number by replacing your code with this:

let
Source = Csv.Document(File.Contents("C:\Users\Mischa\Downloads\FoodMart+CSV+Files (1)\Product-Lookup.csv"),[Delimiter=",", Columns=9, Encoding=1252, QuoteStyle=QuoteStyle.None]),
#"Promoted Headers" = Table.PromoteHeaders(Source, [PromoteAllScalars=true]),
#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"product_id", Int64.Type}, {"product_brand", type text}, {"product_name", type text}, {"product_sku", Int64.Type}, {"product_retail_price", type text}, {"product_cost", type number}, {"product_weight", type text}, {"recyclable", Int64.Type}, {"low_fat", Int64.Type}})
in
#"Changed Type"

Mischa
Frequent Visitor

hi @PC2790

 

Still no success 

Mischa_2-1629983521857.png

 

unsure why it isn't working, I have tried everything I can think of

 

you can find the csv in here 

https://files.onlineintelligence.co.za/f/55e6066262bf4982a15d/?dl=1 

Product-Lookup

 

Could this perhaps be a settings issue?

Hi @Mischa ,

 

It works fine on my device.

10.png


You got this error because your column contents are not only numbers they are alphanumeric so they couldnt totally get converted.  Please convert the error column into text and check if there are any columns that are not numbers.

 

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.

amitchandak
Super User
Super User

@Mischa , I think there is still some character, click on the error and check what error you get, and try to address that. Also change to decimal then currency  first

Hi @amitchandak ! 

 

I have tried TRIM then converting to dec number, whole number or currency. All of which render no results. 

See error message

Mischa_0-1629966802664.png

 

I have also tried Clean and then converting to the various number formats

 

Still no luck 😞

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.