?
Solved

Complex Calculated column

Posted on 2013-02-05
3
Medium Priority
?
307 Views
Last Modified: 2013-02-06
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
0
Comment
Question by:Isaac
  • 2
3 Comments
 
LVL 44

Accepted Solution

by:
Rainer Jeschor earned 2000 total points
ID: 38858237
Hi,
in this way it will work:
1. Use the four calculated columns (from your other question / my suggested calculations)
2. Create a fifth calculated column, set it to return a number with three decimal places and use the following formula
=(1000000*FirstPart)+(1000*SecondPart)+ThirdPart+(0.001*LastPart)

Assuming that each part has a maximum of three digits.

Then the sorting will work:

Sorting by calculated number field
(Note: my initial field name is WBS instead of yours "Metric ID")

HTH
Rainer
0
 
LVL 5

Author Comment

by:Isaac
ID: 38859940
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!
0
 
LVL 44

Expert Comment

by:Rainer Jeschor
ID: 38860277
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
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently came across an issue with a MOSS 2007 deployment where access into some sub-sites were denied, even for the MOSS farm administrators. A bit of background to the setup of this MOSS farm; this was a three server setup, consisting of a fr…
When using a search centre, I'm going to show you how to configure Sharepoint's search to only return results from the current site collection. Very useful when using Office 365 with multiple site collections.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question