How to replace a zero with the number 1, but not in the middle of a number.
Status: Open · Asked by Kari Myers on · 0 views
I'm using Text formatter: replace text to look for a zero and replace it with a 1. But I only want to replace it if the number is actually zero, not in the middle of a number like 205. Is there a way to do this?
Hi @karilynae,
Please try using this Python code to achieve your use case.
def replace_zero(num):
# Check if the number is exactly 0
if num == 0:
return 1
else:
return num
# Test cases
print(replace_zero(205))
try number formatter > spreadsheet formula
IF("{YOUR_NUM}"="0","1","{YOUR_NUM}")


Hi @karilynae,Please try using this Python code to achieve your use case.
def replace_zero(num):
# Check if the number is exactly 0
if num == 0:
return 1
else:
return num
# Test cases
print(replace_zero(205))
Worked great thanks!
try number formatter > spreadsheet formula
IF("{YOUR_NUM}"="0","1","{YOUR_NUM}")
Thanks for the response, I already added the python code, but this looks like it would work as well.
Thanks for the response, I already added the python code, but this looks like it would work as well.
This way does not cost a task!
This way does not cost a task!
Great Point! Thanks for the info!