Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code FABINSIDER for a $400 discount.
Register nowGet inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.
Hi community!
I have a data set where I have a column [Litres] which should be a numerical value, however the people inputting the data sometimes put text. I know I could use a data validation on the original data input sheet, but there are too many to police (and they just copy and paste over the data validation anyway!).
My question is, can I, in the existing [Litres] column replace any text with null and leave the correct values as is (ie numercial values).
OR in a new custom column, can I do an if function that if[Litres] is text then null else [Litres] but I just don't know the correct code for that.
Thanks in advance!
Solved! Go to Solution.
Easiest thing is a new column as you suggest, but use try/otherwise and not if/then/else.
The formula is:
try Number.From([Column1]) otherwise null)
If the conversion to number returns an error, try/otherwise will return null. You can change that to 0 or whatever in the formula.
DAX is for Analysis. Power Query is for Data Modeling
Proud to be a Super User!
MCSA: BI ReportingEasiest thing is a new column as you suggest, but use try/otherwise and not if/then/else.
The formula is:
try Number.From([Column1]) otherwise null)
If the conversion to number returns an error, try/otherwise will return null. You can change that to 0 or whatever in the formula.
DAX is for Analysis. Power Query is for Data Modeling
Proud to be a Super User!
MCSA: BI ReportingThank you so much! Works perfectly
Good day JNelson,
A slight tweak on edhans solution is to transform the column using edhans formula. This avoids creating a new column and having to delete the old column.
= Table.TransformColumns( #"Previous Step", {{"Column1", each try Number.From(_) otherwise null }} )
Hope this helps.
Thank you! That also works 🙂
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!
Check out the February 2025 Power BI update to learn about new features.
User | Count |
---|---|
28 | |
27 | |
22 | |
14 | |
10 |
User | Count |
---|---|
23 | |
21 | |
17 | |
10 | |
9 |