Solved

Complex Calculated column

Posted on 2013-02-05
3
280 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 500 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Pimping Sharepoint 2007 without Server-Side Code Part 1 One of my biggest frustrations with Sharepoint 2007 in the corporate world is that while good-intentioned managers lock down the more interesting capabilities of Sharepoint programming in…
In case you ever have to remove a faulty web part from a page , add the following to the end of the page url ?contents=1
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

830 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