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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
MitchTrott
Frequent Visitor

Conditional Trimming/replacing values

Hi,

 

This is a 2 part question. this is a snippet of what i have:

 

.

.

1.1.1.1

1.1.1.1

1.1.1.1.

1.1.1.1.

 

So my quesiton is this, How can I, firstly, remove the last "." without removing the ones between the 1s? Is there a function where i can remove the last character conditionally?

 

Secondly, how can i remove the lone "." without effecting the .'s between the 1's? Again, is there a condition where i can say "remove "." if its the only character in the cell?"

 

Thank you

1 ACCEPTED SOLUTION
Waldo35
Helper I
Helper I

#"Added Custom1" = Table.AddColumn(#"Added Custom", "Custom.1", each if 
Text.EndsWith([Column1], ".") then if Text.Length([Column1]) = 1 then null else Text.Start([Column1], Text.Length([Column1])-1) else [Column1])

 So this is the code i wrote in the advanced editor.

First it checks if it ends with a  .

if it does end with a dot it takes the entire string except the last character (unless the string is only 1 in length then just return null).  this is to filter out the loose . (record 1 and 2)

 

Result

Waldo35_0-1666181245901.png

 

Code in the custom column (not advanced editor)

if Text.EndsWith([Column1], ".") then if Text.Length([Column1]) = 1 then null else Text.Start([Column1], Text.Length([Column1])-1) else [Column1]

View solution in original post

2 REPLIES 2
Waldo35
Helper I
Helper I

#"Added Custom1" = Table.AddColumn(#"Added Custom", "Custom.1", each if 
Text.EndsWith([Column1], ".") then if Text.Length([Column1]) = 1 then null else Text.Start([Column1], Text.Length([Column1])-1) else [Column1])

 So this is the code i wrote in the advanced editor.

First it checks if it ends with a  .

if it does end with a dot it takes the entire string except the last character (unless the string is only 1 in length then just return null).  this is to filter out the loose . (record 1 and 2)

 

Result

Waldo35_0-1666181245901.png

 

Code in the custom column (not advanced editor)

if Text.EndsWith([Column1], ".") then if Text.Length([Column1]) = 1 then null else Text.Start([Column1], Text.Length([Column1])-1) else [Column1]

Thank you so much! Thats exactly what I was after.

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors