Solved

Complex Calculated column

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Note:  There are two main ways to deploy InfoPath forms:  Server-side and directly through the SharePoint site.  Deploying a server-side InfoPath form means the form is approved by the Administrator, thus allowing greater functionality in the form. …
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

867 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now