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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
EF
Helper II
Helper II

Removing zeros from after decimal point

Hi all,

 

I have a dataset that includes diagnosis codes, and a related dataset that acts as a key to categorize/explain each diagnosis. Problem is that some diagnoses were entered with zeros at the end (which are basically irrelevant) so they don't match the related dataset. 

An easy solution would be to convert to number (since that removes ending zeros) but the codes can include letters so they cannot be converted.

Example:

If I have F41.1, F41.10, F41.100, F90.0, F90, 310, 310.0, 310.00,  309.4, 309.40, 309.41

I want F41.1, F90, 310, 309.4, 309.41

 

Not sure if better in DAX or Power Query.

 

Any ideas?

1 ACCEPTED SOLUTION

  1. In Query Editor select your query that loads your table
  2. Select your column, Diagnosis. choose Transform | Split Column | By Delimiter in ribbon
  3. Make sure delimiter is a period (.)
  4. OK
  5. 2 columns are created, should be Diagnosis.1 and Diagnosis.2
  6. Right click Diagnosis.2 and choose Replace Values
  7. Value to find 0
  8. Replace with leave blank
  9. Select Advanced Options, make sure Match entire cell contents is NOT selected
  10. OK
  11. Zeros are gone
  12. Choose Add Column in ribbon and then Custom Column
  13. Use this formula: if [Code.2] = null or [Code.2] = "" then [Code.1] else [Code.1] & "." & [Code.2]
  14. Remove Diagnosis.1 and Diagnosis.2
  15. Rename your new column Diagnosis
  16. Give Greg a Kudo 🙂

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

15 REPLIES 15

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors