Digits fixing in Numbers

Hi Everyone,

I have a problem to fix end digits of particular string value (Refer attached image), so we need to fix this difference.

I hope someone can help me to solve this issue.

There are probably many different ways but the simplest to me would be to separate the strings, pad the last item, then rejoin the strings back. Like this:

The top is the entire thing in code form:

t5 = String.Split(t6, ["-"]);
strList = List.Transpose(t5);
digits = Get.ValueAtIndex(strList, 2);
rest = Get.ValueAtIndex(strList, 0..1);
t8 = String.PadLeft(digits, 4, "0");
t9 = List.AddItemToEnd(t8, rest);
t10 = List.Transpose(t9);
t11 = String.Join("-", [t10]);

Though to be honest, you are better off fixing the previous code block instead of redoing the naming.

1 Like

And @kennyb6 beat me to it. String.PadLeft prior to the join in your code block is th best way.


And you beat my edit haha.

As @JacobSmall said, in the code block before (Enter Dept Name), you should use pad left instead of the + “00” +

Like this:

Hi Kenny,

Thanks for your immediate response, i have done same like you but something missing in my code.

Also we have series of numbers (U can refer attached image) in my results (Total-187).

Like Ex; 321-1-001 to 009 & 321-2-001 to 321-2-009 & 321-X-XXX

Ah the list levels, didn’t see them. You should try the second post method:

Plug in where your List.Count is into the Code Block containing 1..count; and replace your dept name code block with mine. Also delete the code block with the previous post’s code, you should not need it.

Finally i got answer, thanks for your help guys @JacobSmall @kennyb6:grinning::grinning:

1 Like