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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
Theobu
New Member

Changing Data Type

I am trying to change the data type in the columns that are displayed in text format. The source CSV file is comma delimited. The decimal separator is a PERIOD which is set in the EXCEL ADVANCED options "USE SYSTEM SEPARATORS" which is a PERIOD.

 

However, for some reason the decimal figures are seen as DATA TYPE: TEXT. When changing it to DECIMAL NUMBER in the TRANSFORMATION function, it comes back with an ERROR: "DataFormat.Error: We couldn't convert to Number.
Details:
2.18240547"

 

There are no non-numerical characters in these columns that contain decimal numbers but DATA TYPE remains TEXT.

The same source is used on another machine (Windows 11) and the data is displayed correctly.

 

I tried quite a couple of options to get the data type correct in order for Power BI to generate the required visual, with no success. 

I inserted custom column with the formula as below, and the result comes back with NULL

 

try Number.FromText([YourColumnName][Value]) otherwise null

 

 What do I miss here? 

2 REPLIES 2
Theobu
New Member

Thanks for the prompts response. It is highly appreciated. It is indeed tricky. All the suggestions came to "NULL" 🙂

 

Theobu_0-1733840432094.png

 

123abc
Community Champion
Community Champion

It sounds like you’re dealing with a tricky issue in Power BI. Here are a few steps you can try to resolve the data type conversion problem:

  1. Check Regional Settings: Ensure that the regional settings on both machines are identical. Sometimes, differences in regional settings can cause issues with number formats.

  2. Clean the Data: Use Power Query to clean the data before converting it. You can remove any leading or trailing spaces and ensure there are no hidden characters. Here’s how you can do it:

    • Go to the Power Query Editor.
    • Select the column you want to clean.
    • Use the Trim and Clean functions to remove any unwanted characters.
  3. Replace Errors: Before converting the data type, you can replace errors in the column to handle any unexpected values:

    • In the Power Query Editor, right-click the column header.
    • Select Replace Errors and provide a default value (e.g., 0).
  4. Custom Column Formula: Your custom column formula looks good, but ensure that [YourColumnName] is correctly referenced. Here’s a slightly modified version:

    try Number.FromText([YourColumnName]) otherwise null
  5. Locale Settings: When importing the CSV file, specify the locale settings to ensure that the decimal separator is correctly interpreted:

    • In the Power Query Editor, go to Home > Advanced Editor.
    • Add the following line to specify the locale:
      Source = Csv.Document(File.Contents("YourFilePath"), [Delimiter=",", Encoding=1252, QuoteStyle=QuoteStyle.None, Locale="en-US"])
  6. Manual Conversion: If the above steps don’t work, you can manually convert the text to numbers using a custom function:

    (textValue as text) as number =>
    let
        cleanedText = Text.Trim(textValue),
        numberValue = try Number.FromText(cleanedText) otherwise null
    in
        numberValue

Try these steps and see if they help resolve the issue. If the problem persists, it might be useful to compare the Power BI and Excel settings on both machines to identify any discrepancies. Let me know if you need further assistance!

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.