Solved

Complex Calculated column

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

There is one common problem that all we SharePoint developers share: custom solution deployment. This topic can't be covered fully in this short article, so all I want to do in this one is to review it from a development-to-operations perspectiv…
Microsoft SharePoint Foundation 2010 and Microsoft SharePoint Server 2010 do not offer the option to configure the location of the SharePoint diagnostic trace log files during installation.  This can, however, be configured through Central Administr…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

707 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

15 Experts available now in Live!

Get 1:1 Help Now