Can someone please explain (in a non technical way) how I fix the above error
I have data coming through sa listed below
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:
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)
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.
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.
VAR TestVar = TRIM(Table1[Text])
Hope this helps.
Is this solves your problem please mark as solution.
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
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)
Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.
Click here to read more about the July 2021 Updates
Did you know that you can visit the Power Query Forum in Power BI and now Power Apps
Dont miss our very own April Dunnam’s The Developer Guide to the Galaxy! Find out what the Power Platform has to offer for the traditional developer.