Forum Discussion
abujouz86
Helper II
5 years agoRemove characters convert text to numbers
I have a column of data that includes for example "1 person" or "10/1". I want to remove the characters leaving only the number and if there is a / I want to add the number to the left to the number ...
AntrikshSharma
Community Champion
5 years agoabujouz86 In that case you can try this:
Column =
VAR CurrentCategory = Abu[Category]
VAR AllAlphabets =
SELECTCOLUMNS (
ADDCOLUMNS (
GENERATESERIES ( 65, 90, 1 ),
"Alphabets", LOWER ( UNICHAR ( [Value] ) )
),
"Alphabets", [Alphabets]
)
VAR RemovePeople =
IF (
CONTAINSSTRING ( CurrentCategory, "people" ),
SUBSTITUTE ( CurrentCategory, " people", "" ),
IF (
CONTAINSSTRING ( CurrentCategory, "person" ),
SUBSTITUTE ( CurrentCategory, " person", "" )
)
)
VAR SlashPostion =
SEARCH ( "/", RemovePeople, 1, 0 )
VAR Result =
IF (
SlashPostion > 0,
VAR LeftValue =
MID ( RemovePeople, 1, SlashPostion - 1 )
VAR RightValue =
MID ( RemovePeople, SlashPostion + 1, LEN ( RemovePeople ) - SlashPostion )
VAR Result =
INT ( LeftValue ) + INT ( RightValue )
RETURN
Result,
INT ( RemovePeople )
)
RETURN
Result
abujouz86
Helper II
5 years agoAmazing, thank you thank you thank you!!!