Thank you for your post.
If you have four subsets of the IP address, you can create a calculation field to make all the four subsets a fixed length. For example, assuming the field with your IP Address is named "IP Address", create a calculation field "CALC IP", resulting in Text, with the formula:
[ $p1 = Position ( IP Address ; "." ; 1 ; 1 ) ;
$p2 = Position ( IP Address ; "." ; 1 ; 2 ) ;
$p3 = Position ( IP Address ; "." ; 1 ; 3 ) ;
$x1 = Left ( IP Address ; $p1 - 1 ) ;
$x2 = Middle ( IP Address ; $p1 + 1 ; $p2 - $p1 - 1 ) ;
$x3 = Middle ( IP Address ; $p2 + 1 ; $p3 - $p2 - 1 ) ;
$x4 = Right ( IP Address ; Length ( IP Address ) - $p3 ) ] ;
Right ( "00" & $x1 ; 3) & "." & Right ( "00" & $x2 ; 3 ) & "." & Right ( "00" & $x3 ; 3 ) & "." & Right ( "00" & $x4 ; 3 )
For example, using your example:
10.0.96.1 becomes 010.000.096.001
"CALC IP" does not need to be present on the layout. You only need to sort by "CALC IP" to see the desired results.
Please let me know if you need clarification for any of the above steps.
That worked like a charm!! Thank you soooo much. I almost followed the logic too, () but I would not have been able to come up with that on my own, at least not in the time I have to teach myself these kinds of things.
I am really surprised that it isn't a formatting option for numbers in more software, just like currency, phone numbers, and 5+4 zipcodes. But I am not a programmer so I probably haven't a clue how hard it is to set that up.
I am slightly puzzled by this, because the accepted method of presenting IPv4 addresses is dot-decimal notation - so "10.0.96.1" is already the correct result.
Yes, the accepted method of presenting IPv4 addresses is dot-decimal notationand "10.0.96.1" is the correct result. However, if you sort these fields, you may get something like:
However, you actually want to put the 10.0.96.2 second. That was the problem in the original link mentioned, so "CALC IP" was created for sorting purposes only.
I see no mention of a requirement to sort the records. But if that's the issue, then I would simply convert the IP to a simple (i.e. decimal) number:
Let ( [
octets = Substitute ( IP ; "." ; " " ) ;
W = MiddleWords ( octets ; 1 ; 1 ) ;
R = MiddleWords ( octets ; 2 ; 1 ) ;
G = MiddleWords ( octets ; 3 ; 1 ) ;
B = MiddleWords ( octets ; 4 ; 1 )
W * 256^3 + RGB ( R ; G ; B )
I guess I implied that I needed sorting cability. Sorry. We use static IP's and certain ips are assigned to machines based on whether their primary user is staff, elementary student or high school student. It provides a primitive way to define policies regarding our content filter and stuff.
Anyway, the solution from TSGal worked for my needs. It is nice to know there is another solution though, as it may be a better fit for other people who find this thread.