Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
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?
Thanks for the prompts response. It is highly appreciated. It is indeed tricky. All the suggestions came to "NULL" 🙂
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:
Check Regional Settings: Ensure that the regional settings on both machines are identical. Sometimes, differences in regional settings can cause issues with number formats.
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:
Replace Errors: Before converting the data type, you can replace errors in the column to handle any unexpected values:
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
Locale Settings: When importing the CSV file, specify the locale settings to ensure that the decimal separator is correctly interpreted:
Source = Csv.Document(File.Contents("YourFilePath"), [Delimiter=",", Encoding=1252, QuoteStyle=QuoteStyle.None, Locale="en-US"])
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!
User | Count |
---|---|
119 | |
78 | |
59 | |
52 | |
48 |
User | Count |
---|---|
171 | |
117 | |
61 | |
59 | |
53 |