Sunteți pe pagina 1din 87

2008

Taming the Elusive


Calculated Column
Session Two: Text and Data
This eBook is a collection of articles previously published on
EndUserSharePoint.com.

Dessie Lunsford
EndUserSharePoint.com
12/16/2008
EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

Taming the Elusive Calculated Column: Section Two


By Dessie Lunsford

This is a collection of articles written by Dessie Lunsford, author for


EndUserSharePoint.com from August 2008 through December 2008. A previous
eBook, available to the subscribers of the EndUserSharePoint.com Weekly
Newsletter, includes his first set of articles

You can view all of Dessie’s ‘Taming the Elusive Calculated Column’ articles at
http://www.endusersharepoint.com/?cat=397

This eBook is his contribution to the SharePoint Community.

About EndUserSharePoint.com
EndUserSharePoint.com is a community of SharePoint authors, contributors and
consultants whose mission is to evangelize SharePoint as a solution to common
business problems.

If you enjoy this series of articles in eBook format, please subscribe to the
EndUserSharePoint.com Weekly Newsletter. It is our hope that you will act as our
Evangelist and pass the word on to your friends. Thank you for your continuing
support.

Mark Miller, Founder and Editor


EndUserSharePoint.com

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 2 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

EndUserSharePoint.com: Taming the Elusive “Calculated


Column” - Customizing a Contacts List (Part I)
Filed Under Calculated Column, Dessie Lunsford, Libraries and Lists, Tips and Tricks

Original posting date: August 16, 2008


View all comments:
http://www.endusersharepoint.com/?p=689

The default collection of “Lists and Libraries” within


SharePoint are a great way for most users to begin
collecting and sharing information. Often however,
the defaults may not have the full capabilities you
want in order to present or manipulate the data
they contain in the manner most appropriate for
your organization (see previous series on
“Customizing a Tasks List“).

One of the more robust types of default lists you


can create is the “Contacts” list type. Creating a
“Contacts” list will give you the ability (by default) to collect the majority of all the
information needed to create a reusable “Contact Card” that you’d have in MS Outlook.
It can even be exported from SharePoint as a standard “VCARD” (.vcf file) and
imported directly into Outlook as a contact.

This works fine for most everyone, and I’m not intending this walkthrough as a
replacement for that list since it is rather feature-rich “Out of the box”, but as always,
there is room for improvement.

In many organizations (most, for that matter) each user is assigned a company email
address that is in a standard format.

Examples:

User: John Smith

Company: ACME Inc.

Email Address: john.smith@acme.com (or: john@acme.com, jsmith@acme.com,


etc.)

In the “Contacts” list, there is of course, a field for an email address but the user must
enter in the complete email by hand…which can lead to typos, improper address

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 3 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

formatting, or skipping adding this in altogether because, by default, the field is “Not
Required” (although easy enough to change its setting to be required).

For a listing of “external” contacts, this list normally will work ok since there wouldn’t
be a specific “standard” for their email addresses, but internally, we can remedy the
possibility of human error by instead, making this a calculated column that
automatically gets populated on item creation.

So, how do we accomplish this? Well, first we need to create our contacts list (if you
don’t have one already) so we can begin modifying it.

In SharePoint, create a new list called “Employee Contacts” (choose “Contacts” from
the “Communication” category on the “Create” page).

Once created, open the lists settings page (Settings > List Settings) to see the default
columns that were created:

If you click on the “E-mail Address” column name, you can view the details and options
we have for the column itself. On this “Edit” screen, you’ll notice that we don’t have
the option to convert this column to a “Calculated Column”. Instead we’ll have to

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 4 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

recreate it as a “Calculated” type…so, simply click the “Delete” button at the bottom of
the page to delete the column.

Now, back on the list of columns page (the “Settings” page for the list), click on the
“Create column” link at the bottom of the list to create our replacement column for
email addresses:

Name the column “Email Address”, choose “Calculated” as the type, and leave the
return “data type” as (default) “Single line of text” (Don’t Click “Ok” yet - we’re
going to build our formula and add it in as we go).

For our formula, let’s first decide what is it that we need to get in order to dynamically
build our email address.

For arguments sake, we’ll use the format of jsmith@acme.com for our email address.

In order to build this we need a few things:

 First initial of the contact’s first name


 Full last name of the contact
 Domain name
For the first initial, we can use the “LEFT” function to grab just the first character from
the “First Name” column…which will be:

LEFT([First Name],1)

This function isn’t too complicated as it only has two parts:

1. The text you want to look at


2. The number of characters (starting from the left) that you want to extract
In our case, we want the following:

1. The text you want to look at: column named “First Name”
2. The number of characters (starting from the left) that you want to extract: 1
(first character only)
This will (in the case of “John Smith”) return us the result of “J”.

So, the first part of our formula will be:

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 5 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

=LEFT([First Name],1)

Note - make sure and surround the column name in brackets “[First Name]” since it
has a space in the name, or else the system won’t recognize it as a column.

(Go ahead and add in the above to the “Formula” window in our new column - don’t
click “OK” yet because we still have more to add in)
Next, we need to get the entire last name of the contact.

This is rather simple because all that is required is for us to make a reference to the
column that contains this information:

=[Last Name]

The above will simply display whatever contents appear in the column called “Last
Name”.

Now that we have the last name, we need to add it to the formula we used to get the
first initial. We’ll accomplish this through a method called “Concatenation“.

Personally, I’ve always thought the term was a bit too “Tweaky” for the average user
(typical in computer technology - over exaggerate the complicatedness of the
simple, in order to preserve the “Secret Magic-Inside-the-Box” <insert spooky-sound
here>), but that may also be because the term “Concatenate” is one of the normal
words not commonly used in everyday conversation (unless you’re a programmer).

In its simplest form, “concatenating” strings can be compared to the links on a chain.
Each “link” is a separate string (”word”, or “sequence” of characters), and when
combined (added [not mathematically] to each other), becomes a new string.

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 6 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

How many of you remember the “Soft-Shoe Silhouettes” from the Electric Company?

Examples of this would be:

String 1 = “foot”

String 2 = “ball”

String 1 & String 2 = “football”

String 1 = “black”

String 2 = “board”

String 1 & String 2 = “blackboard”

Notice in the above how I’m using the “&” (”ampersand” or “and”) symbol instead of
“+” (plus). In SharePoint formulas, the “+” symbol is reserved for mathematical
operations on numbers. Since we’re working with text (strings) and actually
appending (add to end) or pre-pending (add to beginning) one or more strings
together, we use the “&” symbol to accomplish this.

In SharePoint, we actually have two completely different approaches to concatenating


strings together, and either will perform the same task.
Method 1: Using an ampersand (&) to combine strings.

As in the examples above, this approach is simply merging two (or more) strings
together with a “&” in between each string.

“mail” & “box” = “mailbox”

Method 2: Using the “CONCATENATE()” function.

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 7 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

This approach uses a function that has two parts:

1. The first string


2. Subsequent string(s) (up to 30 strings)
In our case:

1. The first string = “mail”


2. Subsequent string = “box”
The formula would be:

=CONCATENATE(”mail”,”box”)

Result of the above would again be “mailbox”.

Additionally, if you wanted to add in special separators between strings, you’ll have to
use the first method with the “&” symbol in order to progressively build your resulting
string as you go:

String1 = “pie”

String2 = “in”

String3 = “the”

String4 = “sky”

= String1&”-”&String2&”-”&String3&”-”&String4

The above would result in “pie-in-the-sky”.

Despite researching the benefits of either process of concatenation (using the function
vs. simply the “&” symbol), I’ve yet to determine which method is best as it appears
that it always comes down to personal preference in either’s usage, or whether or not
you’re adding in extra data in between the strings.

So, in order to merge the two pieces of the formula together, we simply take the first
part and add in the second part on the end with an “&” in between the two:
=LEFT([First Name],1)&[Last Name]

Go ahead and update the formula box in our new column to have the above (and again,
don’t click “Ok” yet - we’re almost there).

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 8 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

Next, since this is an email address we’re building, we need to add in our domain name
and format the result into a standard email address format (”name@domain.com“).

We could just grab the text from the “Company” field, but chances are the company
name and web domain name, are actually two different names (or one a derivation of
the other). Instead, we’ll “hard-code” the domain name in to avoid this confusion, and
to gain the added benefit that if someone mistypes in the company name, or if the
domain name changes later, all email addresses on this list will have the same format
and domain name, and will be a single point of entry to make adjustments (name
change) later if needed.

Looking at the formula we have so far, we can see that all we need to do is simply add
in the remaining text using the same method as before:

=LEFT([First Name],1)&[Last Name]

Domain name = “ACME.com”

Include “@” to follow proper email address formatting

Resulting formula is:

=LEFT([First Name],1)&[Last Name]&”@acme.com”

Completing our creation of the new calculated column, go ahead and update the
formula entry text area with the above formula and click the “Ok” button (finally) to
create this new column and add it to our “Employee Contacts” list.

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 9 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

To test our new formula, create a new contact on the list (all you have to fill in is the
“First Name” and “Last Name” fields for this exercise):

Once saved, you’ll see a new item with the contact’s last name, first name, and an
active link for the email address:

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 10 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

Now, you may be wondering “Why did it create the text as a link?” especially since we
didn’t do anything special to tell it that the information it was supposed to display was
going to be a link.

Well, what you may not have realized is that we actually did tell it! Since we made
sure to format the resulting text in a standard email address format, the system is
smart enough to know that it’s supposed to make it an email address link (wow,
something the system did for us automatically that we actually wanted…crazy).

Summary

Hopefully what I’ve shown you here will help in learning how to start building dynamic
data in your lists.

The “Concatenate” function is one of the basic building blocks that once understood,
will become one of your regular “go-to” functions (even if only by means of the simple
“&” symbol) to modify your data, and with the inclusion of the “LEFT” function, we can
see how using different functions together to manipulate the data in a single formula
can make dynamic content generation a nice option that may have not been apparent
before.

In upcoming posts we’ll be looking at how to use more of these functions in


combination, in order to see just how much more functionality we can get out of the
default lists and libraries.

Till next time…


Dessie

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 11 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

EndUserSharePoint.com: Taming the Elusive “Calculated


Column” - Customizing a Contacts List (Part II-I)
Filed Under Calculated Column, Dessie Lunsford, Libraries and Lists, Tips and Tricks

Original posting date: August 26, 2008


View all comments:
http://www.endusersharepoint.com/?p=729

Overview

Last time, we modified the default “Contacts


List” in order to see what other functionality we
could introduce that could extend its default
capabilities.

This is a continuation of the previous article in


which we created a contacts list called
“Employee Contacts” - this post will be using
the same list again.

We began by addressing the need for an easier method of capturing the email address
from “Internal” contacts (looking at this list as an “Employee Contacts” list rather
than “All Contacts“) by developing a calculated column that dynamically builds the
email address based on the contact’s name.

This time, we’ll be looking at an approach we can take in order to “validate” the format
of items entered, specifically a phone number (a question I’ve seen asked many times).

For this initial walkthrough, we’ll be looking at two (of the numerous) standard phone
number formats:

555 123 4567 (with spaces)

555-123-4567 (with dashes)

Each of these is technically a “good” phone number, but depending on your localization
or “data needs”, you will generally have a preference (or requirement) to format all
phone numbers in a specific fashion.

For simplicities sake, we’ll use the format of “555-123-4567” as our targeted phone
number format.

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 12 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

Getting Started

So how do we begin this? We could use “InfoPath” or a custom “coded” solution to


perform the validation since we’d have the power of “Regular Expressions” at our
disposal, but within SharePoint (using only the built-in tools), we have to validate list
items after-the-fact.

Because of this limitation, we’re going to have to manipulate the contents of an existing
column, format it as we need, then display it in a new column (essentially, a “find-and-
replace” operation in the manner in which the system will allow us).

The process we’ll be using isn’t specifically a “find-and-replace”, but for arguments
sake, we can look at it as such in order to have a clearer understanding of just what
we’re trying to accomplish.

To begin, open up Excel and enter in the following in cell A1:


Text to enter: “555 666 7777″

In cell A1, right-click and set the format as “Text” - this will make sure and keep the
contents of this cell in the format we want and not treated as numbers.

This simply gets us a phone number entered in with spaces as the separator.
Next we need to decide how to “find-and-replace” each space with a dash (-).

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 13 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

Since the available functions for our use do not include a


“FindAndReplaceEachOccuranceISpecify()” function, we’re going to have to break
the string apart (similar to a “substring” operation) in order to get at each space and
replace it with a dash.

In cell C1, enter in the following formula:

=TRIM(LEFT(A1,FIND(” “,A1)-1))&”-”&TRIM(MID(A1,LEN(LEFT(A1,FIND(”
“,A1))),LEN(RIGHT(A1,FIND(” “,A1)))))&”-”&TRIM(RIGHT(A1,FIND(” “,A1)+1))

Once the formula is entered in, you should see a properly formatted phone number
appear in cell C1:

Dissecting the formula, we can see several different functions:

3 “TRIM” functions
2 “LEFT” functions
4 “FIND” functions
1 “MID” function
2 “LEN” functions
2 “RIGHT” functions
4 “&” (Concatenate) functions

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 14 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

As discussed in previous articles, we will often have to use several functions in


combination with each other in order to duplicate some of the functionality available in
other platforms (Excel, coded solutions, etc.).

To see how this formula works, we’ll start with what each function does:

TRIM(text) - Removes all spaces from text except for single spaces between words
(this is an important first step since we want to eliminate as much as possible first so
our text is “clean” - this will make the “find-and-replace” more efficient).

LEFT(text, num_chars) - gets the number of characters (from the left) you specify
from a given string.

FIND(find_text,within_text,start_num) - Finds the starting position of text within a


string (finding where in a string a specific character or series of characters begins), and
is case-sensitive.

& - Concatenates strings together (as discussed last time).

MID(text,start_num,num_chars) - Gets a specific number of characters from a string


based on a specified starting point and number of characters to return.

LEN(text) - returns the number of characters in a string.

RIGHT(text,num_chars) - gets the number of characters (from the right) you specify
from a given string.

So, using the above definitions, the formula steps through as:

1. TRIM(remove all spaces from text)


2. LEFT(starting from the leftmost part of the text in Cell A1)
3. FIND(get the first occurrence of a space) - 1 (the minus 1 moves us one
character to the left of the space so we don’t include the space in our selection)
4. Concatenate onto the above a dash (-), followed by:
5. TRIM(remove all spaces from the text)
6. MID(get the length of the text from the leftmost part of the string to the first
space, get the length of the text from the rightmost part of the string (moving
backwards) to the first space - essentially just getting the innermost part of the
text from the first space to the last)
7. Concatenate onto the above a dash (-), followed by:
8. TRIM(removes all spaces from the text)
9. RIGHT(starting from the rightmost part of the text in Cell A1 (moving
backwards))
10. FIND(get the first occurrence of a space) +1 (the plus 1 moves us one
character to the right so we don’t include the space in our selection)

Analysis

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 15 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

As complicated as the above may appear, all we’re doing is separating the string into
three parts:

First part (LEFT) - from the left until a space is encountered (then move one character
to the left so as to not include the space in the selection).

Second part (MID) - middle section of the string (including the space at beginning and
end)

Third part (RIGHT) - from the right (moving backwards) until a space is encountered
(then move one character to the right so as to not include the space in the selection).

On each piece we separate, we run the “TRIM” function to remove any leading and/or
trailing spaces (mainly affecting the “MID” section), and then merge each piece back
together with a dash in between each piece (this serves as our custom version of the
“find-and-replace” operation).

So, with the string “555 123 4567“, we have:

First string = “555”


Second string = ” 123 ” (note the space before and after the “123″)
Third string = “4567”

Trimming the spaces on each (although in this case the first and third strings don’t
have any extra spaces at their respective beginning or ending, it’s a good idea to still
perform the operation anyways since someone may inadvertently add in an extra space
in the list itself) will now make each string “clean” and prepped to be concatenated
back together. Concatenating them (after “trimming”) will now produce our finalized
end result string of:

“555-123-4567”

To get this working on our “Employee Contacts” list in SharePoint, we need to create
our calculated column and modify the formula accordingly to use the phone number
field we want to format.

In SharePoint, go to the contacts list and create a new column called “Home Phone
Number“. Make the new column a “Calculated” type, and paste in the formula from
excel making the following changes:

We’re going to be calculating the phone number entered in the “Home Phone” field, but
using our new field for the view.

Formula in Excel:

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 16 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

=TRIM(LEFT(A1,FIND(” “,A1)-1))&”-”&TRIM(MID(A1,LEN(LEFT(A1,FIND(”
“,A1))),LEN(RIGHT(A1,FIND(” “,A1)))))&”-”&TRIM(RIGHT(A1,FIND(” “,A1)+1))

Replace each occurrence of “A1” with “[Home Phone]“, making sure that you do use
the brackets [] around the name of the column.

Formula in SharePoint:

=TRIM(LEFT([Home Phone],FIND(” “,[Home Phone])-1))&”-”&TRIM(MID([Home


Phone],LEN(LEFT([Home Phone],FIND(” “,[Home Phone]))),LEN(RIGHT([Home
Phone],FIND(” “,[Home Phone])))))&”-”&TRIM(RIGHT([Home Phone],FIND(” “,[Home
Phone])+1))

Hit “OK” to save the column, and then create a new item on the list:

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 17 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

(All you need for this test is to enter in the name of the contact and their “Home
Phone” number in the format of “555 123 4567″ - make sure and use spaces in the
number)

Once saved, you should see our calculated column displaying the phone number in the
proper format (Note - I’ve stripped down the view for readability to only have the
contact’s name and phone numbers visible):

All we have to do now is modify our view to use our column “Home Phone Number”
instead of the default “Home Phone” for display (modify the view and uncheck the
column “Home Phone”).

Editing the item will still be the same in that you’ll actually modify the “Home
Phone” field, but the new column being displayed in the view will add more
consistency in how items are displayed.

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 18 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

Summary

What we’ve done here is take in account for only one of several different phone formats
commonly used, and as a result will only work if numbers are entered in using
the “space” in between each set of numbers (”555 123 4567″), so this is far from
a complete solution as it currently stands (we’ll remedy this in upcoming posts on
this topic).

The hope is that (although incomplete in it’s current state) the process I’ve discussed
here will shed some light on how to begin tackling problems such as these using
nothing more than out-of-the-box functionality…and a little creativity.

Next time, I’ll be continuing on with this same topic as we introduce a second phone
format (dotted separation “555.123.4567″) and how to format it using a different
approach that more resembles a traditional “Find-and-Replace“.

Till next time…

- Dessie

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 19 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

EndUserSharePoint.com: Taming the Elusive “Calculated


Column” - Customizing a Contacts List (Part II-II)
Filed Under Calculated Column, Dessie Lunsford, Libraries and Lists, Tips and Tricks

Original posting date: September 3, 2008


View all comments:
http://www.endusersharepoint.com/?p=742

Overview

Last time, we began working with the concept of


"Data Validation" in a "Contacts" list by creating a
calculated column that reformats a phone number
from a "space-separated" sequence into a "dash-
separated" sequence.

The problem of course, is that as we left it, the only


manner in which it would accurately work is if the
phone number was entered in using the format of "555 123 4567" (not really a
complete solution). So, we need to further extend this by adding in the ability to
check for more formats.

The next format we’re going to look for is the "Dot-Separated" format
("555.123.4567").

The "Dot-Separated" format for phone numbers has seen a rise in popularity recently,
most likely due to the internet and the format used in domains and subdomains, and
although not specifically a standard used throughout the world (most use dashes or
spaces), is nonetheless becoming more and more prevalent and can be found on
(many) business cards, email signature lines, and publications.

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 20 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

Getting Started

Going back to our Excel spreadsheet (refer to the previous article for its setup if you
don’t have it available), we can see the sample phone number we entered and it’s
reformatted version including dashes:

The formula we used for this was:


=TRIM(LEFT(A1,FIND(" ",A1)-1))&"-"&TRIM(MID(A1,LEN(LEFT(A1,FIND("
",A1))),LEN(RIGHT(A1,FIND(" ",A1)))))&"-"&TRIM(RIGHT(A1,FIND(" ",A1)+1))

The above simply breaks the phone number (string) into three parts, uses the "TRIM"
function to remove any spaces, and then merges (Concatenates) the three pieces
back together with a dash in between each.

In this new format ("555.123.4567") however, we have to use a different approach


since there’s no built-in function to remove all "dots". Instead of the "TRIM" function,
we’re instead going to use a combination of "REPLACE" and "SEARCH" (sounds
suspiciously like the original idea of "find-and-replace" doesn’t it?) to get each
occurrence of the "dot" and replace it with a "dash".

You no doubt may be asking why we didn’t take this approach last time for replacing
the spaces with dashes in the "555 666 7777" phone number format. While we could
have with no problems, the previous formula details how to break a string apart in to
multiple pieces (substrings) that can each have a separate process ran on them to

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 21 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

come up with the proper formatting, and using the built-in ability of the "TRIM" function
seemed most appropriate as the method to take. The process detailed this time, uses
a finite depth (how many times it will run on the same data before ending) that will
only allow us to find the first and second occurrences of the "dot". Each additional
search (i.e. "1.222.333.4444") will require additional "nestings" of the "Search and
Replace" functions that will eventually lead to the maximum number of 8 nesting’s
total (Both Excel and SharePoint have this same limitation, although I believe Excel’s
limit is actually 7).

In Excel, enter "555.666.7777" into cell A2 and the following formula into cell C2:
=REPLACE(REPLACE(A2,SEARCH(".",A2),1,"-
"),SEARCH(".",REPLACE(A2,SEARCH(".",A2),1,"-")),1,"-")

As before, notice how the value displayed in cell C2 is formatted with dash-separators?

Dissecting this formula, we can see the following:


3 "REPLACE" functions
3 "SEARCH" functions

REPLACE(old_text,start_num,num_chars,new_text) - Replaces specific text in a string


with the replacement text you want, based on a starting position in the string and
specified length of characters you want replaced.

SEARCH(find_text,within_text,start_num) - Used to find the start position of a


sequence of characters within a string (not case-sensitive).

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 22 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

Analysis

Breaking out the individual functions in order:

REPLACE(has 4 parts)
1. Old_text = starts "REPLACE" function:
REPLACE(has 4 parts)
a. Old_text = A2
b. Start_num = starts "SEARCH" function
SEARCH(has 3 parts)
i. Find_text = "."
ii. Within_text = A2
iii. Start_num = (presumed to be) 1
c. Num_chars = 1
d. New_text = "-"
2. Start_num = starts "SEARCH" function
SEARCH(has 3 parts)
a. Find_text = "."
b. Within_text = starts "REPLACE" function
REPLACE(has 4 parts)
i. Old_text = A2
ii. Start_num = starts "SEARCH" function
SEARCH(has 3 parts)
1. Find_text = "."
2. Within_text = A2
3. Start_num = (presumed to be) 1
iii. Num_chars = 1
iv. New_text = "-"
c. Start_num = (presumed to be) 1
3. Num_chars = 1
4. New_text = "-"
As complicated as this may appear, the logic of what’s taking place can be looked at as:

Complete formula:
=REPLACE(REPLACE(A2,SEARCH(".",A2),1,"-
"),SEARCH(".",REPLACE(A2,SEARCH(".",A2),1,"-")),1,"-")

Nested functions:
SEARCH(".",A2) - rename to SEA1
SEARCH(".",A2) - rename to SEA2

Gives us:
=REPLACE(REPLACE(A2,SEA1,1,"-"),SEARCH(".",REPLACE(A2,SEA2,1,"-")),1,"-")

Taking this a little further:

Nested functions:
REPLACE(A2,SEA2,1,"-") - rename to REP3
REPLACE(A2,SEA1,1,"-") - rename to REP2

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 23 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

Gives us:
=REPLACE(REP2,SEARCH(".",REP3),1,"-")

In the 4 parts of the REPLACE function, we have:

1. Old_text = REP2
2. Start_num = SEARCH(".",REP3)
3. Num_chars = 1
4. New_text = "-"
Again, it can appear complicated at times when using nested functions, but by breaking
them down in a manner such as listed above, it can be easier to see how the logic can
flow.

Another way to look at it is:


=REPLACE(REPLACE(A2,SEARCH(".",A2),1,"-
"),SEARCH(".",REPLACE(A2,SEARCH(".",A2),1,"-")),1,"-")

We know that the "REPLACE" function has four parts:

1. Old_text
2. Start_num
3. Num_chars
4. New_text
"Old_text" is based on the output of the next "nested" function, which in this case, just
happens to be another "REPLACE" function.
"Start_num" is found by performing a "SEARCH" that looks for a dot (.).
"Num_chars" is "1" because all we want to replace is a single dot.
"New_text" is our dash (-).

So, since the "Old_text" is based on the result of a nested "REPLACE", we do the same
thing again.

In the first nested "REPLACE", we again have four parts:

1. Old_text
2. Start_num
3. Num_chars
4. New_text
"Old_text" is cell "A2".
"Start_Num" is based on a "SEARCH" that finds the first dot (.) in cell A2 and returns
its position in the string.
"Num_chars" is again 1" because all we’re looking for is the first occurrence of a dot.
"New_text" is our dash (-).

Running the nested "REPLACE" on the string "555.666.7777" will return us the string
"555-666.7777" (notice the first dot is replaced with a dash and the second dot is still
there?).

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 24 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

This value gets passed back to our original "outer" "REPLACE", which finds the first
occurrence of a dot (in the last part of the string - in between the last "6" and first "7")
and replaces it with a dash (-).

In order to make sure that our starting position is indeed the dot between the last "6"
and the first "7", we have to run a nested "REPLACE" again in the "SEARCH" since
we’re working with the original data in the cell (we can’t pass the value of the original
nested "REPLACE" to our "SEARCH").

So, basically all we’re doing is running a "REPLACE" multiple times (one for each dot
that occurs) in order to switch out each dot character with a dash (clear as mud
yet?).

Moving on to SharePoint, we need to now create a new column in our "Employee


Contacts" list and add in our formula.

In the "Employee Contacts" list, create a new column called "Home Phone Number
2", make it a "Calculated" type and paste in our formula from Excel making the
following changes:

Formula in Excel:
=REPLACE(REPLACE(A2,SEARCH(".",A2),1,"-
"),SEARCH(".",REPLACE(A2,SEARCH(".",A2),1,"-")),1,"-")

Replace each occurrence of "A2" with "[Home Phone]", making sure that you do use
the brackets [] around the name of the column.

Formula in SharePoint:
=REPLACE(REPLACE([Home Phone],SEARCH(".",[Home Phone]),1,"-
"),SEARCH(".",REPLACE([Home Phone],SEARCH(".",[Home Phone]),1,"-")),1,"-")

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 25 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

Hit "OK" to save the column, and then create a new item on the list:

Note - if you have been following along from the previous post on this topic and still
have a test item on the list with the same details as listed below, you can simply
modify the "Home Phone" data to use dots instead of spaces in the phone number. If
not, create a new item as listed below.

(All you need for this test is to enter in the name of the contact and their "Home
Phone" number in the format of "555.123.4567" - make sure and use dots in the
number)

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 26 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

Once saved, you see the original "Home Phone" listed with dots and our new column
displaying the phone number with dashes (Note - I’ve stripped down the view for
readability to only have the contact’s name and phone numbers visible):

As before, all we have to do now is modify the view to use our new column ("Home
Phone Number 2") in the display instead of the default "Home Phone" field (editing the
item afterwards is still the same - modify the "Home Phone" field on the item’s details).

We now have a way to reformat phone numbers that are entered in using a "dotted"
style into our target format of "dashes".

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 27 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

Summary

This (as mentioned last time and at the beginning of this article) is not a complete
solution to the problem since once again this formula will only work on a specific
type of entered phone number (numbers entered in using dots as the
separators). So what we really need is a way to capture both spaces and dots, and
deal with reformatting both of them at the same time.

In the next post, we’re going to do just that - look for phone numbers entered in with a
space-separated style, dot-separated style, and the bonus of checking to see if the
phone number was entered in correctly with dashes in the first place, and skip the
other two checks altogether if so.

Originally, my plan was to include all of these methods into a single article, but after
getting into my first draft and seeing the page count in the high 30’s (and increasing),
I decided to break this up into a series of three posts that first tackle each format
separately, then (as you’ll see in the next article) bring them altogether in a fashion
that uses multiple calculated columns to solve the data validation problem. Even then,
it wont be a complete solution since we’ll only be looking at three (of the numerous)
phone number formats, but by the time we’re finished you should be able to see how to
extend these ideas further and add in as many other formats as you want.

Till next time…

Dessie

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 28 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

EndUserSharePoint.com: Taming the Elusive “Calculated


Column” - Customizing a Contacts List (Part II-III)
Filed Under Calculated Column, Dessie Lunsford, Libraries and Lists, Tips and Tricks

Original posting date: September 21, 2008


View all Comments:
http://www.endusersharepoint.com/?p=758

Overview

In the previous two articles (Part II-I and Part II-


II), we looked at an approach to "Data Validation"
in an "Employee Contacts" list by creating
calculated columns that perform "Find-and-
Replace" operations on a phone number in order to
reformat them into a dash-separated style (555-
666-7777).

Getting Started

This time, we’re going to combine both of those methods into a model that will allow us
to check for two formats ("555 666 777" and "555.666.7777") and reformat them both
to our target format of "555-666-7777", with error checking.

If you haven’t read them yet, I’d encourage you to review both previous articles to get
an understanding of how the formulas work in order to better understand how we’re
going to modify them this time.

In order to be able to catch both types of formats, we need to take on a new approach
that uses multiple calculated columns that each performs a specific function before
displaying our final result of the targeted format ("555-666-7777").
To begin, open Excel and create a new sheet with the following columns:

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 29 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

Our first column ("Home Phone") is where we’ll be entering in our test phone numbers
in each of 3 formats:

"555 666 7777" - (space separated)


"555.666.7777" - (dot separated)
"555-666-7777" - (dash separated)

For the second column ("WithSpaces"), enter in the following formula:

=IF(ISERROR(TRIM(LEFT(A2,FIND(" ",A2)-1))&"-"&TRIM(MID(A2,LEN(LEFT(A2,FIND("
",A2))),LEN(RIGHT(A2,FIND(" ",A2)))))&"-"&TRIM(RIGHT(A2,FIND("
",A2)+1))),C2,TRIM(LEFT(A2,FIND(" ",A2)-1))&"-"&TRIM(MID(A2,LEN(LEFT(A2,FIND("
",A2))),LEN(RIGHT(A2,FIND(" ",A2)))))&"-"&TRIM(RIGHT(A2,FIND(" ",A2)+1)))

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 30 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

This is the same formula as detailed in the first article with the addition of an "Error
Check" in the beginning.

The "ISERROR" function simply attempts to evaluate the formula:

TRIM(LEFT(A2,FIND(" ",A2)-1))&"-"&TRIM(MID(A2,LEN(LEFT(A2,FIND("
",A2))),LEN(RIGHT(A2,FIND(" ",A2)))))&"-"&TRIM(RIGHT(A2,FIND(" ",A2)+1))

If it does not find any errors it goes ahead and performs the calculation to reformat the
space-separated phone number into a dash-separated format and displays it in Cell B2.

If it does find an error (value is not in a space-separated format), it calls Cell C2, which
happens to have another formula in it (that we’ll now setup).

In Cell C2 (our third column called "WithDots"), enter in the following formula:

=IF(ISERROR(REPLACE(REPLACE(A2,SEARCH(".",A2),1,"
"),SEARCH(".",REPLACE(A2,SEARCH(".",A2),1," ")),1,"
")),A2,REPLACE(REPLACE(A2,SEARCH(".",A2),1,"
"),SEARCH(".",REPLACE(A2,SEARCH(".",A2),1," ")),1," "))

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 31 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

This is the formula for checking if the value in Cell A1 is in a dot-separated format. The
formula is similar to the version described in the previous article, but instead of going
ahead and replacing the dot with a dash, we replace it with a space (explained below) -
and like the previous column ("WithSpaces"), we also include error checking.

As in the previous column, the "ISERROR" function simply attempts to evaluate the
formula:

REPLACE(REPLACE(A2,SEARCH(".",A2),1,"
"),SEARCH(".",REPLACE(A2,SEARCH(".",A2),1," ")),1," ")

If it does not find any errors it goes ahead and performs the calculation to reformat the
dot-separated phone number into a space-separated format and displays it in Cell C2.

The reason why we’re replacing the dots with spaces is because the "dot" character is a
"Special Character" in formulas that can be used like a "Wildcard" to "Find Any
Character" (this functionality doesn’t really work in SharePoint, but since SharePoint
calculated columns are based on Excel, problems will occur if trying to search on the
"dot"). Since the limitations in available functions (in SharePoint) does not allow us to
"Escape" (treat as a literal and not a "Special" character) characters, and we already
have the calculated column to handle space-separated formats, we simply convert the
dot-separated phone number into a space-separated number then format it to dash-
separated.

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 32 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

If it does find an error (value is not in a dot-separated format), it simply displays the
value of Cell A2 since it is presumed to be in the correct format of "555-666-7777" (this
presumption is based on the fact that the space-separated format is already handled by
Cell B2 and if it’s not in a dot-separated format and being handled by the current Cell
C2, then it must be in the correct format already - NOTE: for sake of argument, in
our current setup of only being able to handle three formats, we’re always
assuming that the phone number will be in one of the three).
Our next column "DotsToSpaces", is created to handle reformatting the "WithDots"
column into a space-separated format. We need this column because we can’t reuse
our original "WithSpaces" column to also reformat the "WithDots" column since there’s
no way of passing in a second column to format (which is ok because our final column
will help to explain this).

So, in the "DotsToSpaces" column, enter in the following formula:

=IF(ISERROR(TRIM(LEFT(C2,FIND(" ",C2)-1))&"-"&TRIM(MID(C2,LEN(LEFT(C2,FIND("
",C2))),LEN(RIGHT(C2,FIND(" ",C2)))))&"-"&TRIM(RIGHT(C2,FIND("
",C2)+1))),"",TRIM(LEFT(C2,FIND(" ",C2)-1))&"-"&TRIM(MID(C2,LEN(LEFT(C2,FIND("
",C2))),LEN(RIGHT(C2,FIND(" ",C2)))))&"-"&TRIM(RIGHT(C2,FIND(" ",C2)+1)))

Notice how the formula is exactly the same as the "WithSpaces" column, but with a
different Cell reference (Cell C2 instead of Cell A2)?

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 33 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

Question?

Now that we have everything setup to format the phone number, how do we combine
the columns together and display the results in a single column instead of the three
new one’s we just created?

You may be thinking "Can’t we just merge all the formulas together into one huge
one?" Unfortunately (or rather, fortunately in our case since the length of the formula
would be headache-inducing to troubleshoot and debug), we’re precluded from doing
this due to the limited number of nested function we can use (Excel can use 7,
SharePoint can use 8). So, by breaking the functionality into multiple columns that
each has less than the maximum number of nested functions contained within them,
we can use a fourth and final column that references each of them in order to produce
a final result.

Answer:

Our last column called "Home Phone #" will in effect, merge all of the calculations in
the other columns together in order to check which format the phone number is in,
reformat it appropriately and then display the result.

So, in our final column, enter in the following formula:

=IF(ISNUMBER(FIND("-",A2)),A2,IF(ISNUMBER(FIND("
",A2)),B2,IF(ISNUMBER(FIND(".",A2)),D2,"none")))

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 34 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

Looking at this formula, we can see several different things taking place:

3 "IF" functions
3 "ISNUMBER" functions
3 "FIND" functions

Dissecting this formula, we have:

IF(logical_test,value_if_true,value_if_false) - Conditional statement that returns one


value if the condition you are checking is true and another value if false.

ISNUMBER(value) - True/False formula that returns true if a given value is a number


and false if it is not a number.

FIND(find_text,within_text,start_num) - Finds the starting position of text within text


(finding where in a string a specific character or series of characters begins), and is
case-sensitive.

Analysis

Based on the above definitions, for our formula we have:

=IF(ISNUMBER(FIND("-",A2)),A2,IF(ISNUMBER(FIND("
",A2)),B2,IF(ISNUMBER(FIND(".",A2)),D2,"none")))

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 35 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

IF

1. Logical_test
ISNUMBER

a. Value
FIND

i. Find_text: “-”
ii. Within_text: A2
iii. Start_num: (presumed to be) 1
2. Value_if_true: A2 (Cell does contain a dash, so display its contents)
3. Value_if_false
IF

a. Logical Test
ISNUMBER

i. Value
FIND

1. Find_text: ” “
2. Within_text: A2
3. Start_num: (presumed to be) 1
b. Value_if_true: B2 (Cell contains spaces, so call “WithSpaces” to format)
c. Value_if_false
IF

i. Logical_test
ISNUMBER

1. Value
FIND

a. Find_text: “.”
b. Within_text: A2
c. Start_num: (presumed to be) 1
ii. Value_if_true: D2 (Cell contains dots, so call “DotsToSpaces” to
format)
iii. Value_if_false: “none” (displaying the text “none” to signify that
no phone number was found in Cell A2)
As described in an earlier article, what we have is called an "IF-ELSE" chain, or
series of "IF" statements that get called based on the failing (evaluating to false) of a
previous "IF" statement.

This is essentially (with a much cleaner view of the logic):

IF (condition to check)
{Do something if above is “true”, if false, do nothing and move on}
Else IF (condition to check)
{Do something if above is “true”, if false, do nothing and move on}
Else IF (condition to check)
{Do something if above is “true”, if false, do nothing and move on}

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 36 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

Else
{Do Something - think of this as the “cleanup” or “catch-all” - “if none of the above, do
this”}
}

In our case, we’ll be adding in each subsequent "IF" in place of the "FALSE" of each
preceding "IF".

So, we can literally look at our formula as:

=IF(ISNUMBER(FIND("-",A2)),A2,IF(ISNUMBER(FIND("
",A2)),B2,IF(ISNUMBER(FIND(".",A2)),D2,"none")))

“Try and find a dash in the value of Cell A2 and get its start position.
If this start position is a number - meaning we did actually find a dash, display the
value of Cell A2.
If we didn’t find a dash, try and find a space in the value of Cell A2 and get its start
position.
If this start position is a number - meaning we did actually find a space, display the
value of Cell B2.
If we didn’t find a space, try and find a dot in the value of Cell A2 and get its start
position.
If this start position is a number - meaning we did actually find a dot, display the value
of Cell D2.
If we didn’t find a dot, display the text “none” signifying that apparently a
phone number was not even entered in the first place.”

The fun part of this is that since the values of both Cells B2 and D2 are based on
formulas themselves, when our formula in the "Home Phone #" column calls each of
them based on the phone number format, their respective formulas will then run and
display the output back to the original column that called them - in our case, the
"Home Phone #" column (neat huh?).

To test these formulas, go ahead and change the phone number in the "Home Phone"
(our first column) column to be each format and see how the other columns change:

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 37 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

With Spaces:

With Dots:

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 38 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

With Dashes:

No number entered:

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 39 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

To get this working in SharePoint, go to our "Employee Contacts" list (same "Contacts"
list as last time - refer to the first article if you need to create one). Since we’re
modifying the formulas we used previously and need to use different names for the
columns, go ahead and delete the columns we created in the last two articles (skip this
step if you are just now creating the list).

The two columns we had previously used were named "Home Phone Number" and
"Home Phone Number 2" - you can now delete them.

Create a new column called "WithDots":


It’s easier if we create this one first since it doesn’t have any references to other
calculated columns.

Make it a "Calculated" type and enter in our formula from Excel making the following
modifications:
Formula in Excel:
=IF(ISERROR(REPLACE(REPLACE(A2,SEARCH(".",A2),1,"
"),SEARCH(".",REPLACE(A2,SEARCH(".",A2),1," ")),1,"
")),A2,REPLACE(REPLACE(A2,SEARCH(".",A2),1,"
"),SEARCH(".",REPLACE(A2,SEARCH(".",A2),1," ")),1," "))

Replace each occurrence of "A2" with "[Home Phone]" making sure to include the
brackets [] around the column name.

Formula is SharePoint:
=IF(ISERROR(REPLACE(REPLACE([Home Phone],SEARCH(".",[Home Phone]),1,"
"),SEARCH(".",REPLACE([Home Phone],SEARCH(".",[Home Phone]),1," ")),1,"
")),[Home Phone],REPLACE(REPLACE([Home Phone],SEARCH(".",[Home Phone]),1,"
"),SEARCH(".",REPLACE([Home Phone],SEARCH(".",[Home Phone]),1," ")),1," "))

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 40 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

Next Create another column called "WithSpaces" making it a "Calculated" type and
enter in our formula from Excel making the following modifications:

Formula in Excel:
=IF(ISERROR(TRIM(LEFT(A2,FIND(" ",A2)-1))&"-"&TRIM(MID(A2,LEN(LEFT(A2,FIND("
",A2))),LEN(RIGHT(A2,FIND(" ",A2)))))&"-"&TRIM(RIGHT(A2,FIND("
",A2)+1))),C2,TRIM(LEFT(A2,FIND(" ",A2)-1))&"-"&TRIM(MID(A2,LEN(LEFT(A2,FIND("
",A2))),LEN(RIGHT(A2,FIND(" ",A2)))))&"-"&TRIM(RIGHT(A2,FIND(" ",A2)+1)))

Replace each occurrence of "A2" with "[Home Phone]" (using the brackets[]), and
replace "C2" with "WithDots".

Formula in SharePoint:
=IF(ISERROR(TRIM(LEFT([Home Phone],FIND(" ",[Home Phone])-1))&"-
"&TRIM(MID([Home Phone],LEN(LEFT([Home Phone],FIND(" ",[Home
Phone]))),LEN(RIGHT([Home Phone],FIND(" ",[Home Phone])))))&"-
"&TRIM(RIGHT([Home Phone],FIND(" ",[Home
Phone])+1))),WithDots,TRIM(LEFT([Home Phone],FIND(" ",[Home Phone])-1))&"-
"&TRIM(MID([Home Phone],LEN(LEFT([Home Phone],FIND(" ",[Home

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 41 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

Phone]))),LEN(RIGHT([Home Phone],FIND(" ",[Home Phone])))))&"-


"&TRIM(RIGHT([Home Phone],FIND(" ",[Home Phone])+1)))

Create another new column called "DotsToSpaces" making it a calculated type and
enter in our formula from Excel making the following modifications:

Formula in Excel:
=IF(ISERROR(TRIM(LEFT(C2,FIND(" ",C2)-1))&"-"&TRIM(MID(C2,LEN(LEFT(C2,FIND("
",C2))),LEN(RIGHT(C2,FIND(" ",C2)))))&"-"&TRIM(RIGHT(C2,FIND("
",C2)+1))),"",TRIM(LEFT(C2,FIND(" ",C2)-1))&"-"&TRIM(MID(C2,LEN(LEFT(C2,FIND("
",C2))),LEN(RIGHT(C2,FIND(" ",C2)))))&"-"&TRIM(RIGHT(C2,FIND(" ",C2)+1)))

Replace each occurrence of "C2" with "WithDots"

Formula in SharePoint:
=IF(ISERROR(TRIM(LEFT(WithDots,FIND(" ",WithDots)-1))&"-
"&TRIM(MID(WithDots,LEN(LEFT(WithDots,FIND("
",WithDots))),LEN(RIGHT(WithDots,FIND(" ",WithDots)))))&"-
"&TRIM(RIGHT(WithDots,FIND(" ",WithDots)+1))),"",TRIM(LEFT(WithDots,FIND("
",WithDots)-1))&"-"&TRIM(MID(WithDots,LEN(LEFT(WithDots,FIND("

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 42 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

",WithDots))),LEN(RIGHT(WithDots,FIND(" ",WithDots)))))&"-
"&TRIM(RIGHT(WithDots,FIND(" ",WithDots)+1)))

Now, create our final column called "Home Phone #" making it a calculated type and
enter in the formula from Excel making the following modifications:

Formula in Excel:
=IF(ISNUMBER(FIND("-",A2)),A2,IF(ISNUMBER(FIND("
",A2)),B2,IF(ISNUMBER(FIND(".",A2)),D2,"none")))

Replace each occurrence of "A2" with "[Home Phone]" (using brackets []), "B2" with
"WithSpaces", and "D2" with "DotsToSpaces".

Formula in SharePoint:
=IF(ISNUMBER(FIND("-",[Home Phone])), [Home Phone],IF(ISNUMBER(FIND("
",[Home Phone])),WithSpaces,IF(ISNUMBER(FIND(".",[Home
Phone])),DotsToSpaces,"none")))

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 43 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

Once you have all the new columns created, modify the list view to show only the
following columns ("Last Name", "First Name", "Home Phone", "WithDots",
"WithSpaces", "DotsToSpaces", "Home Phone #"):

To test our new functionality, create a new item on the list (for this test, all you need
to enter in is the name of the contact and their "Home Phone" - enter in the
number as "555-123-4567"):

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 44 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

If everything was entered in correctly in our formulas, you should see the following:

Since we entered in our phone number in the correct format, the "Home Phone #" field
simply displays the contents of the "Home Phone" field (no reformatting was
necessary).

To test if the formatting works for the other phone number formats, edit the item and
change the phone number to use the space-separated format ("555 123 4567"):

Notice how each calculated column displays the number and how the "Home Phone #"
column displays the number reformatted to be dash-separated?

Edit the item again and change the phone number to use the dot separated format
("555.123.4567"):

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 45 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

Again, note the differences in how each column displays the phone number and that
the "Home Phone #" column shows the number reformatted into the dash-separated
format.

Edit the item one final time and remove the phone number altogether:

Note the values being displayed. The 0’s in the "WithDots" and "WithSpaces" columns
refers to the "FIND" function not finding anything so a zero is passed back as the
result, and since there wasn’t anything entered in for the number, the "Home Phone #"
column simply displays "none".

The last bit of cleanup is to just modify the view to use only the columns we want - in
this case, just the contact name and our custom column "Home Phone #":

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 46 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

Summary

Sometimes we have to get creative in order to get the job done, especially when the
tools are limited (despite what your "Shop Teacher" may have told you, a "Crescent
Wrench" does make a fine hammer!!). Within SharePoint, imagination and creativity
are a must when working with calculated columns, because sometimes, we have to
create our own way of doing things.

What we’ve accomplished (through these 3 articles), is a method to validate data that
is entered onto a form - a piece of functionality that generally, is only available by use
of custom coded solutions (.NET forms, JavaScript, etc.) or InfoPath as the means to
enter data into our lists.

I’ve always thought that not having the ability to use "Regular Expressions" in
SharePoint was a major flaw - especially since there are so many forms that get filled
out daily (heck, every item on a list is based on filling out a form), but as we’ve seen,
there are (in most cases) ways to accommodate what lacks - we just build our own!!
Granted, what we’ve worked through here isn’t necessarily "Regular Expressions" or
literally "Find-and-Replace" (those would modify the original data), it’s more of a
"lightweight" approach that simply involves string manipulation to get what we want
displayed.

As stated in both the previous two articles, I want to emphasize that what we have
created is not a complete solution; rather it’s more of an idea on how to approach a
given problem. The problem in our case is how do we reformat data on a list? To
really make this a bullet-proof solution, we’d have to take in account for any type of
format as well as length of data, which currently we’re not (this is why "Regular
Expressions" and coded solutions are nice to use for validating data entry - you can
make sure that specific formats and data lengths are adhered to before the data is
saved, not after as is in our case).

Till next time…

- Dessie

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 47 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

EndUserSharePoint.com: Taming the Elusive “Calculated


Column” – Text and Data (Part III)
Filed Under Calculated Column, Dessie Lunsford, Libraries and Lists, Tips and Tricks

Original posting date: October 6, 2008


View all comments:
http://www.endusersharepoint.com/?p=834

The Overview

So far, in the "Text and Data" set of formulas, we


covered the following functions:

 CONCATENATE
 FIND
 LEFT
 LEN
 MID
 REPLACE
 RIGHT
 SEARCH
 TEXT
 TRIM
This time, we’ll continue on by exploring a few more, with some simple examples on
how we can use them in our formulas.

Getting started

To start, let’s look at our two new functions:

CHAR() - function is used to convert a number into it’s ASCII text equivalent (numbers
in the range of 1 through 255).

CODE() - function acts as the opposite of "CHAR()" in that it converts a character into
it’s corresponding numeric code.

Examples:

=CHAR(24) will return

=CODE("©") will return 169

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 48 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

Each of these can be useful in converting exported/imported data from external


programs that use symbols (I believe some that use the "dBASE" format tend to do
this). Personally, I don’t generally work with programs that deal with data like this (all
my data is "human-readable"), but if needed, these functions will give you the ability to
convert back-and-forth if the requirement exists.

As an example though, let’s take a look at a possible Use-Case by examining a need by


a fictitious advertising company.

Case Study

The advertising company, "Bob Loblaw’s Big House of Mad Ads", needs to keep up
a list of all their clients, along with "Catch-Phrases" used by them in their ad
campaigns.

One client, "Mom’s Old Fashioned Baked Goods", recently started sponsoring an
outreach program to local teens with a series of bake sales targeted to aid in
fundraising endeavors by the teen’s in after-school activities. Working with the ad
company, they came up with the catch-phrase: "Roll in the Dough TM" to help inspire
the teens participating in the fundraisers.

Chip Loblaw, needs to create a list in their company portal that contains the client
name and their "Trademarked" catch-phrase.

In MS Word, it’s fairly simple to just use the "Insert" menu to find the "Trademark"
symbol (TM), or you can just use the keyboard shortcut of "Alt+Ctrl+t" (although for
me at least, I don’t have every single shortcut memorized). So, it can be as easy as
simply creating your list in Word, then "copy/paste" into a list within SharePoint since
special symbols will copy over.

In this scenario however, let’s see what we can do with a calculated column to handle
this for us.

Since we need the "Trademark" symbol, let’s insert one into an Excel spreadsheet so
we can see how we can work with it.

In Excel, click "Insert > Symbol":

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 49 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

In the window that open, click on the "Special Characters" tab then click on the
"Trademark" entry and then the "Insert" button at the bottom, then close the window:

This adds in the TM symbol to our sheet:

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 50 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

Now that we have our symbol, let’s see what its numerical value is. We do this by
means of the "CODE()" function.

In our spreadsheet, in Cell B2, enter in the following formula:

=CODE(A1)

This should return the number 153.

Next, we’ll add in our phrase and combine it with the trademark symbol using the
"CHAR()" function.

In Cell C1, type in the text "Roll in the Dough".


In Cell D1, enter in the formula: =C1&" "&CHAR(B1)

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 51 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

Alternatively, you could just add in the number directly to the formula instead as:

=C1&" "&CHAR(153)

(The above yields the same results of "Roll in the DoughTM", and is how we’ll do it in
SharePoint)

We now have the catch-phrase and symbol joined, displaying the result of "Roll in the
Dough TM".
Within SharePoint (per the requirement of our buddy "Chip"), we’ll illustrate this
through a custom list called "Client List".

In SharePoint, create a custom list (Site Actions > Create > Custom List > Name it
"Client List").

Once created, open the list settings and rename the "Title" column to "Company
Name".

Next, create a new column called "Catch Phrase" leaving all defaults ("Single line of
text", etc.).

After these, create another new column called "Trademark", make it a "Calculated"
type, and enter in the following formula:

=[Catch Phrase]&" "&CHAR(153)

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 52 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

The last step is to modify the default view of the list to only show "Company Name"
and "Trademark".

Once this is complete, we can enter in the information for "Mom’s Old Fashioned Baked
Goods":

Upon saving, this will display as:

So, Chip now has the start of his list in which he can compile a complete archive of all
their clients and catch-phrases.

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 53 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

Summary

Is there a better approach to this specific example? Possibly. We could have simply
copied in the special symbol directly into our formula (since SharePoint does allow for it
to be pasted in directly) making it slightly smaller:

=[Catch Phrase]&" TM"

This may be the approach you want to take since it’s more straight-forward and doesn’t
rely on any extra functions to make it work, but in an attempt to come up with a
"working" example of how to use both functions (since I never have to deal with the
numerical equivalents of ASCII characters), this seemed like the simplest way to
walkthrough a real-world example (so in the end, choose the approach that works best
for you).

Next time, we’ll be continuing on by looking at three more functions in the "Text and
Data" set that all aid in formatting text (LOWER, UPPER, and PROPER).

Till next time…

- Dessie

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 54 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

EndUserSharePoint.com: Taming the Elusive “Calculated


Column” – Text and Data (Part IV)
Filed Under Calculated Column, Dessie Lunsford, Libraries and Lists, Tips and Tricks

Original posting date: October 17, 2008


View all comments:
http://www.endusersharepoint.com/?p=868

Overview

In this article, we’re going to look at how to


transform existing text on a list in order to format it
into a more consistent manner.

Typically, you may have many different users


entering in form information onto your lists.
Because of this, it’s very common for each user to
enter in the text on the individual form fields
differently using non-standard formats.

Some of the more common examples would be:

1 - URL’s (web addresses) - browsers are by nature case-insensitive when its comes to
the address for a particular site, but its human-nature to substitute in our own linguistic
nuances when conveying information, so it’s extremely common to see an address of
“http://www.ThisIsMySite.com”, when in all actuality the address could be
“http://www.thisismysite.com”, “http://www.THISISMYSITE.com”, or even
“http://www.tHiSiSmYsItE.com”. This common occurrence is due to how the brain
attempts to find logical patterns and meaning within information (hence the reason why
most people capitalize the first letter of each word in a URL).

Excerpt from
http://www.saps.gov.za/docs_publs/publications/journal/june04/face.htm:

Read through the following paragraph quickly without over-examination of the words.

“The phaomnnehil pweor of the hmuan mnid

Aorccdrnig to rscheearch at Cmabrigde Uinervtisy, it deosn’t mttaer in waht oredr the


lteers in a wrod are, the olny iprmoetnt tihng is taht the frist and lsat ltteer be at the
rghit pclae. The rset can be atotal mses and you can sitll raed it wouthit a prbelm. Tihs

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 55 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

is bcuseae the huamn mnid deos not raed ervey lteter by istlef, but the wrod as a
wlohe. Amzanig huh?

If you are like most people, your image smarts shuffled the letters without much effort.
Your visual intelligence searched for patterns and completed meanings. The result?
Your understanding of the individual words and the paragraph as a whole was as clear
as if every letter had been correct in the first place.” - 2003. Judy Piatkus, London

2 - Email Addresses - although technically, these are case-sensitive in the “local-part”


of the address (i.e. jsmith@email.com is not the same as jSmith@email.com), because
of interoperability, most (if not all) ISP’s treat any form of a user’s name in the address
as equivalents (jsmith = jSmith = JSmith = JSMITH). As a guideline however, all email
address assigned should be in a complete lowercase format in order to avoid any
confusion (see RFC2821 section 2.4), unless a requirement exists for a specific SMTP
server for the address to be formatted differently (all uppercase, first letter capitalized,
etc.)
3 - Usernames (in Active Directory) - although you can create usernames using a
format that includes case (i.e. John Smith), usernames in Active Directory are not case-
sensitive (jsmith = JSmith). A common action by users is to enter in their name using
a “Proper” format when logging in, but is unnecessary as Windows will authenticate
them regardless of the format used when entering in the name.

Getting Started

Because of these three common occurrences, many users will enter in information on
lists using a mix of formatting types, which can lead to inconsistencies in how the list
items appear.

To get around this and provide for a way for a list administrator to “clean-up” some of
this erroneous data, we can use a technique involving a calculated column to first
reformat, or “transform“, the list data into the “text-case” we want, then replace the
original text through a data view.

First though, let’s take a look at the three SharePoint functions that we can use in this
text-transformation process:

LOWER() - converts all uppercase letters in a text string to lowercase.

UPPER() - converts all text in a string to uppercase.

PROPER() - capitalizes the first letter in a string word, then converts the remaining
characters in the string to lowercase. If the string has more than one “set” of

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 56 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

characters (word), it looks for any non-letter characters and uses it as a separator for
the next word. After the separator, it again capitalizes the first character of the next
“set” of characters (word), and then converts the remaining characters in the set to
lowercase (literally, this will capitalize the first character of each word in a sentence).

Examples of the above three function would be:

Text: “John”

Formula: LOWER(”John”)

Result: “john”

Text: “john”

Formula: UPPER(”john”)

Result: “JOHN”

Text: “look at How this text gets TRANSFORMED”

Formula: PROPER(”look at How this text gets TRANSFORMED”)

Result: “Look At How This Text Gets Transformed”

Using these, lets look at an example of a SharePoint “Contacts” list to see how we can
go back and clean-up entries that were entered in non-standard formats.

Case Study

In SharePoint, create a “Contacts” list (”Site Actions > Create > ‘Communications’
column > Contacts”) called “Contacts”.

Once created, modify the default view to display only the following columns:

“Last Name”

“First Name”

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 57 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

“E-mail Address”

“Web Page”

Create several new items on the list (filling in only the information listed in the view),
but use a variety of upper/lower-case variations in the “E-mail Address” and “Web
Page” fields.

Looking at these entries, there’s nothing “technically” wrong with how they appear, but
in order to keep consistency throughout the list, we’ll want to format all of the records
in the same fashion using the style of the “Edison Smithington” contact as our target
goal.

To accomplish this, we’re going to run through a few steps.

Steps

First, let’s look at the format of the email address for “Edison”. It’s in an all lowercase
format, so based on the definitions of the three functions I gave at the beginning, the
“LOWER()” function is what we’ll be using.

Second, we’ll create a calculated column and perform the text-transformation using
our formula on the “E-Mail Address” column.

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 58 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

Third, we’ll use a technique designed for Excel to copy our newly transformed text
back into the original column to update all the records simultaneously and apply the
change.

This technique is described at http://support.microsoft.com/kb/263580, but we’ll have


to modify it slightly to work in SharePoint.

Since we’ve already decided on the function to use (”LOWER()”), we can now move on
and create our calculated column.
In the “Contacts” list, create a new column called “TextTrans”, make it a “Calculated”
type, enter in the following formula, and leave the checkbox marked for “Add to default
view”:

=LOWER([E-mail Address])

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 59 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

Once saved, you should see the new column displayed on the list with the email
addresses transformed into the proper format (converted to lowercase).

In order to update the actual “E-mail Address” column with the newly transformed text,
we’re going to switch to “Edit in Datasheet” (Actions > Edit in Datasheet) and simply
copy the text from the “TextTrans” column and paste it into the “E-Mail Address”
column.

Switch to “Edit in Datasheet”.

This will switch us to the “Datasheet” view.

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 60 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

In the dataview, “Left-click and hold” on the first cell of the “TextTrans” column (not
the column title, but the first email address), then drag down until you have selected
each of the 4 cells containing the transformed email address:

Once you have them all selected, “Copy” what you have selected (”Right-click” and
choose “Copy”, or use the keyboard shortcut “Ctrl+C”).

Next, select the 4 cells in the original “E-mail Address” column using the same
technique listed above (”Left-click and hold” then drag down). Once you have them
selected, “Paste” in the contents of the “TextTrans” column (what you currently have
on the clipboard), to overwrite the existing content.

Once you have pasted in the new formatted email addresses, switch back to the
“Standard View” (from the “Actions” menu”) to see the updated results (they appear in
the data view as well, but this is our verification step).

(Animation showing the process)

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 61 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

Summary

As you can see, the process is actually pretty simple, and although I’ve only highlighted
the “LOWER()” function in this example, you can use the other two in a similar fashion
to reformat other columns data to adhere to whatever standards you may need for
keeping your data consistent.

For the other two functions (”UPPER()”, and “LOWER()”), examples of these would be
(no screenshots needed for these - the above example should be enough to get you
going):

 Use the same technique on both the “First Name” and “Last Name” columns with
the “PROPER()” function to reformat the names in a standard “First-letter
capitalized” fashion to catch any case-typing errors. This will transform whatever
is entered into each of these into a standard of the first letter being capitalized
and the remaining letters converted to lowercase.
 Use the same technique again on the “Company” column with the “UPPER()”
function to transform the company names to all uppercase (this may, or may not
be appropriate for your specific needs, but will server as an example of how to use
the function since it acts in a similar manner to the “LOWER()” function).
Next time, we’ll be continuing on by looking at five more functions in the “Text and
Data” set that all aid in validating, formatting, and modifying text (ASC, CLEAN,
EXACT, REPT, T).

Till next time…

- Dessie

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 62 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

EndUserSharePoint.com: Taming the Elusive “Calculated


Column” – Text and Data (Part V)
Filed Under Calculated Column, Dessie Lunsford, Libraries and Lists, Tips and Tricks

Original posting date: October 31, 2008


View all comments:
http://www.endusersharepoint.com/?p=898

Overview

Last time, we looked at 3 functions for formatting


the case of text (working with uppercase and
lowercase letters, as well as the “Proper” format of
first letter capitalized only in a word).

In this article, we’re going to look at a few more


tools we have in the “Text and Data” set of
functions that can give you increased options in
how to validate and transform data in your lists.

The five functions we’ll be looking at are:

*ASC - Converts “full-width” (double-wide) characters into their corresponding “half-


wide” (single-byte) equivalents. Useful in language conversions where the typical set of
“ASCII” characters are not enough to encompass the (possible) thousands of characters
used in the language (also see “Double-Byte Character Sets in Windows“). (Example:
full-width text “ファズ・ギター” converts to half-width “ファズ・ギター” equivalent - notice the
size and spacing of the characters before and after conversion?)

CLEAN - Strips out all non-printable characters from text. Used to format text that may
have originated from a separate program or data source that in its output includes low-
level code (such as “” blocks) that can’t be printed.

EXACT - Used to compare two strings to see if they are identical. This function uses
“case-sensitivity” to determine if the compared values are exactly the same and
displays a simple “Yes” or “No” based on the comparison result.

REPT - Used to repeat a character (or characters) a number of times (useful in adding
a series of repeated characters to an existing string.

T - Used to get the text of a given value and display it if (and only if) the value is text
(will display nothing if the value is a non-text type - i.e. number or Boolean result).

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 63 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

*I wont be covering examples of the “ASC()” function (other than the example given in
its definition) since its usage requires a system that can render the “Double-wide”
characters (international settings), but suffice it to say that the function can be useful
during language conversions to deal with the character sets used.

For the remaining 4 functions, let’s look at some examples of their usage:

Getting Started

The “CLEAN()” function is useful when moving data from one type of system to
another in that it allows you to remove any characters that do not directly represent a
written symbol (“Non-Printing”, or “Control” characters), but rather, represents a
specific action or formatting on the data itself. Examples of this would be “line feeds”
and “tabs” (or anything that doesn’t fall in the Decimal 32-127 and 128-255 ASCII
ranges - “Printable” and “ASCII Extended” respectively - http://www.ascii-
code.com).

To see how this works (using the example of “tabs“), open a blank text document
(Notepad, WordPad, etc.), and enter in the numbers 1-5 separated by tabs.

In SharePoint, create a new “Custom List” named “Sample Calculations” (these will
be simple examples, so if you want, you can use any list since we’ll be creating the
columns as we go).

In the list, create a new column named “Raw Text“, make it a “Single line of text”
type, leave the rest as default and click “OK”.

Create a new item on the list and paste in the tab-separated list of numbers from your
text document.

Once saved, you’ll see the entry containing the numbers separated with spacing
(although appearing like single spaces, it is in fact tab-separated).

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 64 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

Create another new column called “Cleaned Text“, make it a “Calculated” type and
paste in the following formula (leave the rest as default - “Single line of text” for
returned type):

=CLEAN([Raw Text])

Once saved, notice the “Cleaned Text” column has stripped away all the spacing
(tabs)?

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 65 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

You may be thinking, “Why don’t we just use the “TRIM()” function to remove the
extra spaces?” Although this will remove any irregular spacing in text, the “Tab”
character is not equal to the “Space” character, so it would be ignored in the “TRIM()”
function.

Next, create another item on the list, but replace the “tabs” with a series of spaces that
equal the same spacing the tabs created.

Visually, they do appear the same, but the background information (code) that renders
the information is very different.

Upon saving, notice how the spacing remains intact?

This is because although visually appearing the same, the “space” character is a
printable character, and will be rendered literally.

Notice how SharePoint treats spaces compared to tabs - the spaces are treated literally,
whereas the tabs get “trimmed” down some on the visual display to preserve space
(because of this internal “trimming”, attempting to “copy” it from the list and paste it
back into another document will result in it being space-separated instead of tab-
separated).

Looking at the source (viewing the raw html) of the page you can see that the “tab-
separated” entry will appear as:

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 66 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

And the result after the calculation:

Looking at our test comparison of “space-separated”, we can see it as:

(The calculated column also displays the exact same html).

So, even though it “appears” to be not in a “tab-separated” format in the visual


presentation, it is still tab-separated, so the calculation will indeed work.

The next function “EXACT()”, is used to compare strings (text) to determine if they
are the same and uses case-sensitivity in its comparison. Because of this we should
observe the following:
String1 = “Ice Cream”
String2 = “ice Cream”
String1 is not = to String2

Because of case-sensitivity, these two are not identical and will result in “No”.

=EXACT(”Ice Cream”, “ice Cream”)


Result = No

To test this function, we’ll use the example above (”Ice Cream”) in our SharePoint list.

Create two columns, called “Text1” and “Text2“, making them both “Single line of
text” leaving all as default.

Create another new column called “Comparison“, make it a “Calculated” type and
enter in the following formula (leave as “Single line of text” for return type):

=EXACT([Text1],[Text2])

As soon as you save the new column and return to the view of the list, you’ll notice that
the “Comparison” column already displays “Yes” for any existing items. This occurs
because in their current state, both the “Text1″ and “Text2″ columns contain the same
thing (nothing), so the “EXACT()” formula will return true.

Once created, add a new item to the list and add in the following:

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 67 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

“Text1″ column: “Ice Cream”


“Text2″ column: “ice Cream”

Once saved, the “Comparison” column will evaluate the two fields and return the result
of whether or not they contain the same information, which in this case, is “No” since
they are not identical based on the rules of “Case-Sensitivity” (note - for readability, I
removed the previous two columns from the view and filtered out the results to only
display those with a title containing “Comparison”).

Modifying the text in “Text2″ to make the first letter capitalized would change the result
to “Yes”, but if we wanted to make allowances for case-insensitivity for future entries,
we can modify our formula to include the use of the “PROPER()” function (detailed
last time) to make each field in the same case before comparing them.

Formula:
=EXACT(PROPER(”Ice Cream”), PROPER(”ice Cream”))

Becomes:
=EXACT(”Ice Cream”, “Ice Cream”)

Result = Yes

To do this in our list, modify the formula in the “Comparison” column as:

=EXACT(PROPER(Text1),PROPER(Text2))

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 68 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

After saving, go back and view the list to see that the “Comparison” field now displays
“Yes” as its result since it is now first converting each field into a proper format before
comparing.

Obviously the above may not work for all scenarios since you may want differences
(some things should not be capitalized for example), but in some cases the data you
may be working with is coming from a different system and may require a
“preparation” before you can work with it.

In my organization for example, we have a system that will only accept capitalized
input, so it’s extremely common for users to forget to switch back from “Caps Lock”
when exiting the system - causing them to type in all capital letters for some time
before realizing it. The data we extract from this system has to be prepped first by
using something like the “PROPER()” technique, before we can use it in SharePoint.

The next function we’ll look at is the “REPT()” function. This function simply displays
a string (character or series of characters) a specified number of times.
Examples:

=REPT(”*”,10)
Result = **********
(Literally: “Display the asterisk character 10 times”)

=REPT(”0″,5)&”Alpha”
Result = 00000Alpha
(Literally: “Display the zero character 5 times followed by the text ‘Alpha’)

One approach you can take with this is to build out your own type of ID numbering
system that follows a specific pattern, or total character count (mentioned in a previous
article comment).

The idea is to have for example, a 10 digit number as the ID while allowing for shorter
numbers that get entered to be formatted with the 10-digit convention.

This example uses a process of checking the value entered to see if it’s less than 10
digits, and if so, adds in the required amount of “zero’s” to pad the left (start) of the

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 69 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

number to make it 10 digits in length. If the number entered is indeed 10 digits, it will
simply display the number.

The formula for this is:

=IF(LEN(Number)<10,REPT(0,(10-LEN(Number)))&Number,TEXT(Number,”0″))

This formula literally steps along as:

If the length of [Number] is less than 10, create an amount of zero’s equaling the
difference between 10 and the length of [Number] then display these zero’s followed by
the [Number]. If the length of [Number] is not less than 10, display the number using
the “TEXT()” formatting option to display it in a number format.

Examples:

Number = 12345
Result = 0000012345

Number = 1234567890
Result = 1234567890

Moving this into SharePoint, create a new column called “Number” and make it a
Number type with no decimal places (this could also be a “Text” type column since
we’re not performing any mathematics on the value of the column - I just chose
“Number” for this example).

Create another new column called “ItemID“, make it a calculated type and enter in the
following formula:

=IF(LEN([Number])<10,REPT(0,(10-LEN([Number])))&[Number],TEXT([Number],”0″))

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 70 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

Once saved, if you return to the list you’ll see immediately that the “ItemID” column is
now populated with 10 zero’s (note - I’ve again trimmed the view to only display the
current two columns we’re working with for readability).

This occurs because the “Number” field is currently empty, so its length is (obviously)
less than 10, and since the difference between its length (0) and the maximum length
we determined (10) is 10 (10-0=10), the result is 10 zero’s.

Now, lets edit the item and add in a value to the “Number” column (add in any value
you want as long as it’s not longer than 10 characters in length - for this example, I’ll
just add in “12345″).

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 71 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

Once saved we’ll see the “ItemID” column update to include the value entered in the
“Number” column along with our padding of zero’s to make it still equal 10 characters
in length.

Note the format of the value in the “Number” column? This is because we specified it to
be a “Number” type initially and it will format the entered values based on numerical
convention (hence the comma). Since we’re not actually performing any mathematical
calculation on the value in the column itself, we could/can go into its settings and
change it from a “Number” type to a “Single line of text” type without experiencing any
problems.

The next steps for this would be removing the “Number” column from the view, and
possibly adding in the functionality in the formula to allow for numbers longer than 10
digits (possibly trimming off anything longer, or displaying a text message to inform
users that they need to shorten it).
The last function we’ll be looking at this time is the “T()” function. This function is
used to see if a specific value is text, and if it is, display the text (if its not, it wont
display anything).

To use this function, you simply pass in a reference to a column and it will check to see
if its value is text.

Formula:
=T([Column Name])

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 72 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

Looking at our standard (”Out of the box”) column types, we can see what this means:

Column types (with example names):

1. Single line of text (Col1)


2. Multiple lines of text (Col2)
3. Choice (Col3)
4. Number (Col4)
5. Currency (Col5)
6. Date and Time (Col6)
7. Lookup (Col7)
8. Yes/No (Col8)
9. Person or Group (Col9)
10. Hyperlink or picture (Col10)
11. Calculated (Col11)
Testing each of these with the “T()” function, we will see the following results:

=T([Column Name])

Using Col1, Col2, or Col3 will result in the values of those columns being displayed
since they each have a return type of text (the calculation will return “True”, so it
displays the text of the evaluated column).

Col4, Col5, and Col6 will all result in nothing being displayed since each of them has a
return type that is not text (calculation will return “False” since Col4 is a number, Col5
is currency, and Col6 is Date/Time).

Col7 and Col9 are both *unusable since calculated columns cannot reference a
“Lookup” or “Person or Group” column.

*Note - although “technically” unusable, there are, what can be considered “Hacks” or
“Workarounds”, to bypass the errors you will see when attempting to make a reference
to one of these types of “Calculation-Incompatible” columns.

For example, create a “Text” column then make a reference to it in your formula. Once
the calculated column is created, go back and change the data type of the original
“Text” column, or delete it and recreate it with a different data type - reusing the
original name.

Although some of these types of techniques do work (the now infamous “Today”
column trick), you can’t always rely on that approach since many times, it wont
produce the results you may be expecting. Attempting to use the example mentioned
above (modifying the input column data type after-the-fact) to induce usability of a
“Lookup” or “Person or Group” column, in this case, still won’t work since even though
the error message has been bypassed, the formula still recognizes the incoming data as
incompatible.

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 73 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

Col8 will also be blank since a “Boolean” (yes/no, on/off, 1/0) value is not text.
Col10 although not directly usable (Calculated columns cannot directly reference a
“Hyperlink” type column), it can be “forced” to be usable through the technique
mentioned above (create a “text” column with the name you want, make a reference to
it in your calculated column then go back and delete the “text” column and recreate it
as a “Hyperlink” column). The result will be that the formula will display the “text” only
of the link (not the actual hyperlink itself).

Using the same concept in the above example, but instead using the “Format URL as:
Picture” option of the “Hyperlink or Picture” column type, the “T()” function will display
the “Alt text” of the image.

Col11 will return only values that are in a “text” format, so if the to-be-tested
calculated column value is for example, a number, the result will be blank (if it’s text, it
will display the text value).
Uses of the “T()” function could include “data validation” that involves the inclusion of
an “IF()” function to display “friendly” messages if the data is not-text:

Example:

=IF(ISERROR(VALUE([Column Name])),IF((T([Column Name])<>”"),[ Column


Name],”Field is empty or not ‘text’-only”),”Field is empty or not ‘text’-only”)

This formula steps through as:

If the value of [Column Name] is not a number, or if the value of [Column Name] is not
empty, display the value of [Column Name]. If the value of [Column Name] is a
number, not blank, or anything but text, display the message “Field is empty or not
‘text’-only”.

In this case, the “VALUE()” function looks to see if the data in the [Column Name]
column is representing a number, and if so, converts it to that number. Because the
function returns an error (#VALUE!) if it’s not a number (number being a constant
number, date, or time format), we have to wrap it in an “ISERROR()” function to
remove the error from being displayed. Since we also want to decide how to handle it if
an error is found, we wrap the “ISERROR” function in an “IF()” function that proceeds
to further calculations depending on whether or not there was an error. If it does not
find an error (the value is a numerical format), we display a friendly message to the
user reminding them to only enter in text. If it does find an error (meaning the value in
the column is not in a numerical format), we then test to see if the value is empty. If
it’s not empty, we can safely display the value (which will be text). If it is empty, we

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 74 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

display a friendly message to the user reminding them that they can only enter in text
and that the field cannot be empty.

There’s obviously other ways of handling parts of this (make the column “Required” so
we can omit the “check for blank” step), but the idea here is to show different
approaches you can take (many ways of “Skinning-The-Cat that is SharePoint”), to give
you the most flexibility available.

Summary

Next time we’ll be concluding the series on “Text and Data” covering the last 4
functions in the set by discussing “DOLLAR“, “USDOLLAR“, “FIXED“, and “VALUE“.

Till next time…

- Dessie

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 75 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

EndUserSharePoint.com: Taming the Elusive “Calculated


Column” – Text and Data (Part VI)
Filed Under Calculated Column, Dessie Lunsford, Libraries and Lists, Tips and Tricks

Original posting date: November 25, 2008


View all comments:
http://www.endusersharepoint.com/?p=955

Overview

In this article, we’re going to be covering the last 4


functions in the "Text and Data" set of formulas for
SharePoint.

The four functions we’ll be discussing are:

DOLLAR - Converts a given number into text with


it represented in a "Currency Format" and having
it’s decimals rounded to a specified place. The
format used in this function to convert the number to the appropriate text convention is
"$#,##0.00" (this text format is automatically applied - so you don’t have to specify it
directly)

USDOLLAR - Same as the "DOLLAR" function in that it takes a given number and
converts it to text (into a "Currency Format" with the decimals rounded), but it differs
in that it will use a standard "U.S. Currency" format instead of what your local
computer may be set to (international settings).

FIXED - Also similar in how both the "DOLLAR" and "USDOLLAR" functions format a
number into text, but differs in that the "FIXED" function simply formats the text result
into a decimal format using a period and commas (not necessarily currency - this will
just represent the text version of a number, whereas the "DOLLAR" and "USDOLLAR"
will pre-pend on a "Currency" symbol to the result - i.e. "$").

VALUE - Converts a text string that represents a number into a number (the first three
described above all take a number and convert it to text - this one works the other
direction taking text and converting it to a number).

Example of these functions would be:

Text: "12345"
Formula: DOLLAR("12345")
Result: $12,345

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 76 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

The above will return a currency-based result displayed in the currency-specific regional
settings you have applied to your local computer (which may be overridden by
whatever regional settings applied in your instance of SharePoint).

Text: "12345"
Formula: USDOLLAR("12345")
Result: $12,345

The above will return a currency-based result that uses the standard U.S. Currency
convention.

Text: "12345"
Formula: FIXED("12345")
Result: 12,345

The above will return a numerical result in a 3-character-grouped-comma-


separated-2-decimal place format (that was a mouthful).

Text: 12345
Formula: VALUE(12345)
Result: 12,345

Although appearing the same as the original input (text), the outputted result of this is
a number converted to a standard numerical format which includes a comma
("#,##0.00").

Getting Started

To see how these can work in a SharePoint list, we’ll look at the example of a "Loan
Calculator" used to determine monthly payments on an amount of money borrowed.

For this, we’ll create a custom list that will allow us to build out our calculated columns
and test how these functions work (we’ll look at each one as we create the columns).

In SharePoint, create a "Custom List" called "Loan Calculator".

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 77 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

Once created, we’ll create several new columns in order to have the list perform the
calculations we need.

First, to have the items that will appear on the list make a bit more sense, simply go
into the list settings ("Settings > List settings") and rename the "Title" column to
"Loan Title".

Next, we’ll create our columns using the following:

Create a new column called "Years" making it a "Number" type. Give it a description
of "Total Number of Years on the Loan" and set its "Number of decimal places" to "0"
and uncheck "Add to default view" (we’ll be displaying it in another column).

Create another new column called "Payments per year" making it a "Number" type.
Give it a description of "Total payments per year (monthly payment, weekly, etc.)" and
set its "Number of decimal places" to "0" and uncheck "Add to default view" (we’ll
also be displaying it in another column).

Create another new column called "Annual Rate" making it a "Number" type. Give it
a description of "Annual percentage rate on loan" and set its "Number of decimal
places" to "4", and check the box to "Show as percentage".

Create another new column called "Loan Amount" making it a "Single line of text"
and give it a description of "Total loan amount (in dollars and cents)".

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 78 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

Create another new column called "Total Payments" making it a "Calculated" type.
Enter in the following formula and set its return type to "Number" with "0"
decimal places:

Formula:

=Years*[Payments per Year]

This calculation is simply multiplying the number of years of the loan, by the number of
payments per year.

Example:

Years = 10
Payments per year = 12
Formula = 10*12
Result = 120

Create another new column called "Payment Rate" making it a "Calculated" type.
Enter in the following formula and set its return type to "Number" with
"Automatic" for the decimal places (we don’t know how many it will have yet, so
this will leave plenty of room for us), and uncheck "Add to default view" (we’ll be
referencing this column in another calculated column so it doesn’t need to be displayed
on its own):

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 79 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

Formula:

=[Annual Rate]/[Payments per Year]

This formula will take our "Annual Rate" and divide it by the total payments per year to
give us the total of the rate that will be applied each month.

Example:

Annual Rate = 5.5%


Payments per year = 12
Formula = .055/12
Result = .004583333

Create our final column called "Payment Amount" making it a "Calculated" type.
Enter in the following formula and set its return type to "Single line of text":

Formula:

=FIXED(-PMT([Payment Rate],[Total Payments],[Loan Amount]))&" ("&[Payments per


year]&" times per year for "&[Years]&" years)"

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 80 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

Note - since we’re working with money in this exercise, we’re also taking advantage of
one of the available functions in the "Financial" set of formulas for SharePoint called
"PMT". I’ll be discussing this in future articles when I delve into this set of functions,
but since we’re using it here, the "PMT" function is used to calculate the payments for a
fixed-rate loan using regular or "Constant" payments and a constant interest rate.

The function has the form of:

PMT(rate,nper,pv,fv,type)

Rate - interest rate for the loan


Nper - total number of payments for the loan
Pv - principal (present value, or total amount that a series of future payments is worth
now)
Fv - future value, or cash balance you want to attain after the last payment is made.
This is an optional field in the function and will be presumed to be "0" if omitted.
Type - either a "0" or "1" indicating when payments are due (0 = end of the payment
period, 1 = beginning of the payment period. Presumed to be "0" if omitted since this
value is also optional in the function)

Dissecting the Formula

In our formula for the "Payment Amount" column, we can look at it as:

=FIXED(-PMT([Payment Rate],[Total Payments],[Loan Amount]))&" ("&[Payments per


year]&" times per year for "&[Years]&" years)"

The "PMT" function is in the format of: PMT(rate,nper,pv,[fv],[type])

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 81 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

Note - items in brackets [] are optional (we’re not using them in this case).

Stepping through the calculation, we first calculate the current payment by the
following:
(Original Principal)*((1 + interest per period)^(number of periods)*(interest per
period)/((1+interest per period)^(number of periods)-1)

Example:

(P)Original Principal = 250,000


(I)Interest per period = (Annual rate)/(payments per year) = .055/12 = .00458333
(N)Number of periods = 360 (based on 30 year loan with 12 payments per year:
30*12=360)

=(P*((1+ I)^N)*I)/((1+ I)^N-1)


=(250000*((1 + .004583333) ^360)* .004583333) /((1 + .004583333) ^360 -1)
Result = -1419.472441

Since this number (-1419.472441) needs to be reflective of a dollar-type number, we


take it and pass it to the "FIXED" function to set it as a number with only two decimal
places and a comma.

=FIXED(Result) = -1,419.47

Also, since this specific calculation is returning a negative number, we use the "FIXED"
function with a minus (-) in front of the data it needs to format:

=FIXED(-Result) = 1,419.47

After we have our value, we then "CONCATENATE" a little more information onto the
final result in order to make it more easily understood (optional, but can assist in
readability):

=FIXED(-Result) ]))&" ("&[Payments per year]&" times per year for "&[Years]&"
years)"

This produces a final result of: "1,419.47 (12 times per year for 30 years)"

Testing the Solution

Now that we have our columns setup, let’s create a new item on our list and see what
happens.

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 82 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

On the list, create a new item filling in each of the fields with data:

Loan Title = Home Loan


Years = 30
Payments per year = 12
Annual Rate = 5.5
Loan Amount = 250000

Upon saving the item, we’ll see the calculations have taken place and show the results:

 "Annual Rate" is displayed as a percentage.


 "Total Payments" shows how many payments it will take to pay off the loan.
 "Payment Amount" displays how much is due each payment with frequency.

This works, and does give us the accurate calculations of the loan and payments, but
notice how the "Loan Amount" and "Payment Amount" values are represented a
numbers, but not in a "Currency" format? Let’s go back to our column settings and
make a few changes to make the display of these values more relevant to the task (this
is money we’re working with, so it should look like money!)

In the list settings page, click on the "Loan Amount" column to edit its properties.
Change its type to "Currency" and leave the rest as default. Once saved (click OK on
the prompt warning you about the possible loss of data - we wont be losing anything),
go back to the list and view the item again.

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 83 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

The "Loan Amount" column now reflects a currency format for its value (we could’ve
just used this format when we originally created the column, but I wanted to show that
in many cases you can change it after the fact without any consequences).

Next, we need to look at the "Payment Amount" column and modify it so the value
displayed will also be in a currency format.

Looking at our formula again:

=FIXED(-PMT([Payment Rate],[Total Payments],[Loan Amount]))&" ("&[Payments per


year]&" times per year for "&[Years]&" years)"

All of our numerical formatting is being applied based on the first function "FIXED".
Since that function formats the text into a standard numerical format with commas and
a fixed decimal length of two places, it’s actually using the "TEXT" format of
"#,##0.00" (Seem familiar? Look back at the beginning of this article in the
description for "DOLLAR").

As a test to see if this is accurate, modify the formula in the "Payment Amount"
column to be the following:

=TEXT(-PMT([Payment Rate],[Total Payments],[Loan Amount]),"#,##0.00")&"


("&[Payments per year]&" times per year for "&Years&" years)"

Notice any difference in the values being displayed for the item? You shouldn’t
because the formatting will be the same.

Modify it again, but this time, add in the dollar sign "$" in the formatting:

=TEXT(-PMT([Payment Rate],[Total Payments],[Loan Amount]),"$#,##0.00")&"


("&[Payments per year]&" times per year for "&Years&" years)"

Now, when looking at the results, we’ll see the value displayed in a currency format:

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 84 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

Again, this does work, and is a manner in which you can have complete control over
the formatting of the results, but since we’re just working with the "Currency" format,
we can skip this method and instead use the built-in shortcut functions that deal with
currency directly. These are of course, "DOLLAR" and "USDOLLAR".

In my case, since I do work in the States, and my international settings for both my PC
and my instance of SharePoint are also set for U.S., using either function on my
machine will both produce the exact same result. The idea though, is that if you are on
a machine that has International settings other than those for the U.S., using "DOLLAR"
will display the result in the local currency format (that which is specified on your local
machine), whereas using the "USDOLLAR" function will always produce results
formatted to meet U.S. Currency.

To use these, modify your formula accordingly, depending on which you want:
=DOLLAR(-PMT([Payment Rate],[Total Payments],[Loan Amount]))&" ("&[Payments
per year]&" times per year for "&Years&" years)"

=USDOLLAR(-PMT([Payment Rate],[Total Payments],[Loan Amount]))&" ("&[Payments


per year]&" times per year for "&Years&" years)"

So, as I’ve stated in several articles, there a many different ways of accomplishing the
same task within SharePoint, it just depends on your needs, the amount of control you
want to have, and what the result should be. Each of these approaches will all do the
job, but may differ in their results somewhat depending on regional location, personal
customizations, and how you approach the formulas, but they do all work, and I’d
encourage you to work with each of them to see what other differences you may find.

The last function I want to mention is the "VALUE" function. This function is used to
convert text that represents a number, into an actual number. It works with each of the
three standard numerical formats (constant number, date, time), and will return an
error ("#VALUE") if the text is not in one of these.

Examples:

Text = "12345"
Formula = VALUE(Text)
Result = 12,345

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 85 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

The above returns the formatted number 12,345 since the inputted text represented a
number. Also, notice how the result comes through formatted with a comma? Once
again, we find another function using the same formatting type of "#,##0.00".

To prove this, look at the following examples:

Text = "12345.99"
Formula = VALUE(Text)
Result = 12,345.99

Text = ".0599"
Formula = VALUE(Text)
Result = 0.0599

Notice how each result gets formatted (note the added leading zero on the second
example)?

Summary

Part of the reason I grouped these four functions into the same article is because of this
commonality they each have in their formatting of the results. Each uses as it’s base
format, "#,##0.00", but can differ somewhat depending on the situation (regional
settings).

Granted, we did actually cover a fifth function "PMT" in considerable detail (which we
will be looking at more when I get to the series that covers that set of functions), but it
seemed necessary since we were working with a set of formulas involving money, so
you got one for free!!

Till next time…

- Dessie

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 86 of 87


EndUserSharePoint.com – No GeekSpeak on SharePoint 2007

A Final Note From Dessie

This is the last in the series dedicated to the "Text and Data" set of functions as we’ve
now covered each function in the set, but we will be revisiting many of these in future
articles since this particular set is probably the most frequently accessed (and
questioned about).

Thank you for your continuing support. I look forward to seeing you at
EndUserSharePoint.com for the next series of Taming the Elusive Calculated Column in
SharePoint.

Till next time…

- Dessie

EndUserSharePoint.com, All Rights Reserved, 2008 – 200 Page 87 of 87

S-ar putea să vă placă și