The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event: Join us in Stockholm, September 24-27, 2024.
Save €200 with code MSCUST on top of early bird pricing!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
Hi,
Can someone please explain (in a non technical way) how I fix the above error
I have data coming through sa listed below
<div>116</div>
<div>18</div>
I'm unable to change the data source so I need to fix it wthin Power BI desktop. For the above data I'm after the numbers 116 and 18.
I have created a column that looks at the data and with a series of RIGHT function, LEN function and SUBSTITUDE function formulas I now have a column with just the numbers however it is still recognised as text and not a number.
I have tried converting the column from text to number and it fails given the the error in the subject line of this message.
Any help would be appreciated
I would suggest fixing this issue from inside the Edit Queries section. What you need to do is to remove the <div> and the </div>. Then you will be left with something you can convert to Number.
The easiest method is to open Edit Queries. Find the query that contains these values. Click on the column with these values and do this:
Finally! I've been working on this for way too long.
My issue wasn't specifically the "<div>" existing in my table, but this suggestion sent me down the path of considering some possible blank or null rows in the source (I had assumed there were none). Once I filtered out all blank rows, my date conversion worked perfect.
Thank you!
yeah tried that as well and failed... did a find replace of the <div> and replaced with nothing and same with </div>... it actually removed all data.. and do not leave the numbers remaining
You must have made an error. The Replace Values function only replaces the substring that you give it.
A more technical solution would be "Add Column" -> Custom Column. Call the field whatever name you like and have the both be:
= Text.Start(Text.End(Text.Trim([NumberField]), Text.Length(Text.Trim([NumberField])) - 5, Text.Length(Text.Trim([NumberField])) - 11)
It does not recognise the commands
That is a Power Query formula. Click on "Edit Queries" and find the query with your table of information. Select "Add Column" in the ribbon and find "Custom Column". There is a box for the column name and then a box for that particular formula. Once you click ok, you'll see a new version of the table with an attempt at processing the formula. Any errors will be displayed and you can tweak the formula to get it correct.
Close and Apply will attempt to import your data again with this new column included.
I'm resorting to trying to go back to the source data and fix at that end......
@Anonymous,
Try creating a new column with VALUE() DAX function:
Column = VALUE(Table1[Text])
This should convert the text to number.
Aletrnatively you can do your text cleanup (substitute, trim, etc.) in a variable and then finally return the number.
Column =
VAR TestVar = TRIM(Table1[Text])
RETURN
VALUE(Table1[Text])
Hope this helps.
Is this solves your problem please mark as solution.
tried the value function in new column.... failed
Can you check whether you have any garbage values in your column like "
What I have been doing (as a means to get to the bottom of it) is a serires of calculated columns to ensure each step works...
Step one was a column removing all garbage prior to the numbers which was
Right('Table1[text],LEN('Table1[text])-8)
NOTE: in the column with the currupt data not every row is populated is I started the above with a "if "" do ""
I had to go minus 8 in the above formula to get rid of wrap text... the data had 2 blank lines then on the 3 line it had the text.
This succesfully created a column from
<div>116</div> changed data to 116</div>
<div>18</div> changed data to 18</div>
In the second calculated column I did a substitute function to substitute </div> with nothing (so "").
Then just as an extra layer (but probably not needed) I did a trim function to ensure no random spaces were left in the data.
From there I'm left with a column that appears to be just the numbers but is text and I cannot conver to a number (or value)
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the August 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
111 | |
80 | |
78 | |
43 | |
37 |
User | Count |
---|---|
158 | |
111 | |
64 | |
59 | |
54 |