Skip to Content
0

# concatenation function in Webi

Sep 20, 2017 at 05:49 PM

104

Hi

I have Material field and some materials are 4 digit and some are 5 digits

Users want to see zero with 4 digit material code e.g 01234 but dont want to see zeros with 5 digit code.

I have concatenated the material with 0 in the beginning of every material but since it is also showing 0 with five digit material code as well which is not acceptable.

Is there a logic I can write while concatenate on the material field that it only add 0 in front of 4 digit material but not add anything before 5 digit

for example,

Field: Material Code:

01234 ( zero before the material code)

05678 ( zero before the material code)

01000 ( zero before the material code)

87694 (no zero before the material code)

Will appreciate the help.

Thanks

* Please Login or Register to Answer, Follow or Comment.

### 3 Answers

Best Answer
AMIT KUMAR
Sep 20, 2017 at 08:13 PM
0

try this.

=if(length([material])=4) then "0"+[material] else [material]

Show 1 Share

Excellent, Thanks alot Amit, Appreciate your help.

AMIT KUMAR
Sep 20, 2017 at 06:04 PM
0

use this.

=if(length([material]=4)) then "0"+[material] else [material]

Show 1 Share

HI Amit,

Is something wrong with my syntax, please let me know, Thanks (Material is Item, same thing)

capture.png (5.6 kB)
William Ayd Sep 20, 2017 at 11:12 PM
0

While Amit's solution works, I'd suggest using the LeftPad function. For what you've asked it wouldn't make a difference, but LeftPad will be generally more useful as it could ensure that items of even 3, 2, or 1 characters in length will always have the appropriate amount of zeros added in front to make them 5 characters long

`=LeftPad([Item]; 5; "0")`
Show 1 Share

Thank You William