Newbies erickaz Posted May 15, 2012 Newbies Posted May 15, 2012 I am working with an inventory database where each record has a number which is formatted with a letter prefix followed by a number, sometimes sub-numbers. example TS.1 TS.2.1 TS.2.3 TS.10 TS.15 TS.15.1 TS.20 My issue is now sorting it as it appears above, whether I set the field type as number or text, it still sorts like this. TS.1 TS.10 TS.15 TS.15.1 TS.20 TS.2.1 TS.2.3 Any suggestions on how I can sort them as if they were files in finder on a mac. Thank You.
eos Posted May 15, 2012 Posted May 15, 2012 Create a new calculation field with this formula; substitute mySerialNumber with your serial number field. Make sure result type is number. Then sort by the new field. The formula assumes that, as in your sample data, the prefix is three characters long and the sub-number is one digit. Adjust it for other formats. Let ( [ theField = Replace ( mySerialNumber ; 1 ; 3 ; "" ) ; hasPoint = PatternCount ( theField ; "." ) ; pointPosition = Position ( theField ; "." ; 1 ; 1 ) ] ; Case ( hasPoint ; Left ( theField ; pointPosition - 1 ) + ( Right ( theField ; 1 ) / 10 ) ; theField ) )
comment Posted May 15, 2012 Posted May 15, 2012 You'll have to sort by a calculation field (result is Text), e.g. = Let ( [ words = Substitute ( OriginalField ; "." ; " " ) ] ; LeftWords ( words ; 1 ) & SerialIncrement ( "000000000" ; MiddleWords ( words ; 2 ; 1 ) ) & SerialIncrement ( "000000000" ; MiddleWords ( words ; 3 ; 1 ) ) ) The original field should be of type Text.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now