Forum Discussion

Niels_NL's avatar
Niels_NL
Advocate I
10 years ago
Solved

Remove leading zero's from a string

Hey guys,   the situation is as follows: I have a set of values (string-type) that can either contain a number or the value 'AFW' (i.e.: unknown data). However, some numbers have leading zero's at ...
  • sdjensen's avatar
    10 years ago

    Hi,

     

    You could try something like this. This code will first check if the string can be converted into a number - if it can't then it will just return the string else it will convert the string to a number (removing leading zero's) and then turn the number back into a string.

     

    NumberXNoLeadingZero = 
    IF(
    	ISERROR( VALUE( 'Table'[NumberX] ) ),
    	'Table'[NumberX],
    	CONCATENATE( VALUE('Table'[NumberX]), "" )
    )