Removing a zero in the third place of a text string if found
I have data that the zero varies where it is located. Some examples would be AA01 or AA01x as well as AA10, AA10x, etc.
The first two characters are always letters and I want to return the rest of string without a zero in the third place. So if the first column is AA01x, I want the next column to display AA1x. While if the first column has AA10, I want it to return AA10.
I tried =SUBSTITUTE(Column@row, "0", ""), but when I have AA10 or AA01 it returns AA1 in both cases. I need it to display AA10 & AA1.
Thanks in advance!
Best Answer
-
This formula will work assuming there are always at last numbers after the AA
=SUBSTITUTE(LEFT(Column@row, 3), "0", "") + MID(Column@row, 4, LEN(Column@row) - 3)
Darren Mullen, join the Smartsheet Guru Elite
Get my 7 Smartsheet tips here
Author of: Smartsheet Architecture Solutions
Answers
-
This formula will work assuming there are always at last numbers after the AA
=SUBSTITUTE(LEFT(Column@row, 3), "0", "") + MID(Column@row, 4, LEN(Column@row) - 3)
Darren Mullen, join the Smartsheet Guru Elite
Get my 7 Smartsheet tips here
Author of: Smartsheet Architecture Solutions
-
Hi Scott,
To solve your problem, you need a formula that specifically checks if the "0" is in the third position of the string and removes it only in that case. Here's how you can do it:
Use this formula in the desired column:
=IF(MID(Column@row, 3, 1) = "0", LEFT(Column@row, 2) & MID(Column@row, 4, LEN(Column@row)), Column@row)
Explanation:
MID(Column@row, 3, 1)
extracts the third character from the string.IF
checks if that third character is "0".- If it is "0", it concatenates:
- The first two characters:
LEFT(Column@row, 2)
- The rest of the string starting from the fourth character:
MID(Column@row, 4, LEN(Column@row))
- The first two characters:
- If the third character is not "0", it simply returns the original string:
Column@row
.
Example Output:
- Input: AA01x → Output: AA1x
- Input: AA10 → Output: AA10
- Input: BB02y → Output: BB2y
- Input: CC20 → Output: CC20
This ensures that only a "0" in the third position is removed, while other parts of the string remain unaffected. Let me know if you need further assistance!
Ask Me About Smartsheet Maps?!?!
Solving Automation, Integration, & Adoption Problems For Smartsheet Customers
Account Executive | Skyway Consulting Co
-
I get "#UNPARSEABLE" with the following formula - =IF(MID([Primary Column]@row, 3, 1) = "0", LEFT([Primary Column]@row, 2) MID([Primary Column]@row, 4, LEN([Primary Column]@row)), [Primary Column]@row)
I do have other text on the back end as well (-1 / -2 / etc.). See below screenshot
I am 100% sure it is me.. HAHA Thanks again!
-
=SUBSTITUTE… Worked..
Thanks again!!
Help Article Resources
Categories
- All Categories
- 14 Welcome to the Community
- Customer Resources
- 64.4K Get Help
- 424 Global Discussions
- 221 Industry Talk
- 465 Announcements
- 4.8K Ideas & Feature Requests
- 143 Brandfolder
- 144 Just for fun
- 61 Community Job Board
- 463 Show & Tell
- 32 Member Spotlight
- 1 SmartStories
- 300 Events
- 39 Webinars
- 7.3K Forum Archives
Check out the Formula Handbook template!