I need to transform the data in this way:
print(format_number(1)) # Output: 00000-01
print(format_number(100)) # Output: 00001-00
print(format_number(12345)) # Output: 00123-45
print(format_number(999999)) # Output: 99999-99
I need to transform the data in this way:
print(format_number(1)) # Output: 00000-01
print(format_number(100)) # Output: 00001-00
print(format_number(12345)) # Output: 00123-45
print(format_number(999999)) # Output: 99999-99
Iām sure there are better ways of doing this but I would just treat it as a string left padded with leading zeros and then just do simple left/right string manipulation to create the formatted output you want.
Something like this where the length of the input number doesn't matter since you are just taking the right 7 characters
Welcome to the Community, Fredrik!
I would do it like that:
LET num = padstart([Numbers], "0", 7)
left(num, 5) & "-" & right(num, 2)
formatted-number.morph (2.5 KB)
Yes. This works!