Link to home
Start Free TrialLog in
Avatar of Isaac
IsaacFlag for United States of America

asked on

Complex Calculated column

I have a column called "Metric ID" and I would like to create a calculated column that adds a 0 to each of the single digits like below so I can sort. This is SP 2007.

1.1.1.1 => 01.01.01.01
1.2.1.1 => 01.02.01.01
10.1.1.1 => 10.01.01.01
16.1.8.5 => 16.01.08.05
17.2.9.1 => 17.02.09.01
2.1.1.1 => 20.01.01.01
1.1.3.1 => 01.01.03.01
1.1.1.5 => 01.01.01.05
ASKER CERTIFIED SOLUTION
Avatar of Rainer Jeschor
Rainer Jeschor
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Isaac

ASKER

Rainer,

Thanks!  It worked but could you please break down the formulas.  I would like to understand your thinking.

=(1000000*FirstPart)+(1000*SecondPart)+ThirdPart+(0.001*LastPart)

Also, please explain this too.
Second part
=LEFT(RIGHT([Metric ID],(LEN([Metric ID])-(LEN(FirstPart)+1))),(SEARCH(".",RIGHT([Metric ID],(LEN([Metric ID])-(LEN(FirstPart)+1))),1)-1))

I just want to understand it all.

Thanks!
Hi,
as you mentioned, the sorting on the calculated columns is not working as expected and you can only choose two columns to be sorted on in the list view.

Therefore I convert the extracted parts into numbers and giving them the right "weight".
By multiplying the first part with one million and adding the second part multiplied with 1000, the third part with no "weight" and the last one with a division by 0,001 I will get a correctly formatted number

1.0.1.0 == 1000001.0
10.0.10.0 == 10000010
10.1.0.0 == 10001000

The second part calculation works like this:
Take the right part without the first part.
In this string search the next "." and take the left part of it.

HTH
Rainer