Identify Resources by Gantt Bar Colors

 Back to Project Management

For a long time Project users have been asking for the option to display distinctive Gantt Bars for tasks that are assigned to specific resources or groups of resources. A new feature in Project 2000 can help you achieve that goal: the custom fields with formulas. With Project 98, the only close solution (without building a macro) is to filter the tasks. Using a custom flag field (Flag1), we will build a formula that will check if a specific resource is assigned to the task. Then we will use this flag field to make a Gantt bar appear for this task.

The Customized Field

To customize a field I usually insert it in a table first and then right-click on its header to select the Customize Fields command. That brings me directly to that field in the Customize Fields dialog box. So, insert the Flag1 field in your task table and select Customize Fields.

By clicking on the Rename button, you'll be able to rename the field. This will also change the default title for the field to your own label instead of "Flag1". In my example, I'll rename the field "Tom Test".

Clicking on the Formula button opens the formula editor where all the tools you need to build the formula can be found.

A little like in Excel, you will have to create a formula with one or more functions that return a value for each task in the table. But the comparison stops here since the functions used are based on Visual Basic Script and are not exactly like those in Excel.

Note: For more information on VBScript, visit http://msdn.microsoft.com/scripting/default.htm?/scripting/vbscript/


The first function we will use is the IIf() function (spelled with two capital i's) which is very similar to the Excel IF() function. Click the Function button and select "IIf" from the General submenu on the Function menu. Project will insert the IIF() function for you with its three arguments defined as follows:

IIf( expression, truepart, falsepart ) 

The "expression" argument refers to a test that returns "true" or "false" and the other arguments are the values the function will return in each case. We will test the Resource Names field to see if it contains a particular resource. In my example, I'll test for Tom.

To insert the Resource Names field, double-click the "expression" argument to select it; then select the field from the Text submenu on the Field menu. You'll notice that brackets are used to enclose field names. (You could have typed the field name in as well – just remember to include the brackets.)

Now type an equal sign ("=") and a value in double-quote marks (like "Tom"). Since Flag fields only accept Yes or No values (or True and False), we will replace the "truepart" with Yes and the "falsepart" with No. The formula at this stage looks like this:

IIf([Resource Names]="Tom",Yes,No) 

Testing the formula will get you the results shown in Figure A: 

Figure A


As you can see, the formula works only if Tom is the only one assigned to the task and if he's assigned 100% to it. That's because our test expression requires that the Resource Names field to be exactly equal to "Tom", not that the field contains "Tom". We will need the InStr (In String) function to do a contains test. 

The InStr() function has these arguments:

InStr( start, string1, string2, compare ) 

Or,  as I like to describe it:

InStr( start, BigString, SmallString, compare ) 

BigString and SmallString define what to search for and where to search for it: search  BigString (the Resource Names field) to see if it contains SmallString ("Tom").

The start argument tells Project where the search should begin within BigString, and is mandatory (unlike in regular VBScript). Use the number 1 to start searching at the first character in BigString.

The compare argument is an optional flag with the value 0 or 1, and it tells the function how to compare text. A value of 0 causes a binary comparison (meaning it finds exact matches only – which means for us that it is a case-sensitive search). A binary test fails if it's asked to compare "Tom" and "tom". A value of (1) causes a textual search (which is not case-sensitive). Binary (0) is best used here since we don't want the test to say that "Tom" is found in words like "Atomic" or "Phantom". However, be aware that the binary search will say that "Tom" is found in both "Tom" and "Tomas"; so, your resource names need to be carefully chosen for this function to work properly.  
 

Note: If you leave a blank in place of the compare argument then Project uses a textual comparison as its default - unlike VBScript where a binary comparison is the default. 

The InStr() formula should look like this:

InStr(1,[Resource Names],"Tom",0) 

and the complete  formula should now look like this:

IIf(InStr(1,[Resource Names],"Tom",0),Yes,No) 

The InStr function returns the position of the first character where a match is found, or 0 if it can't be found. So the IIF() function receives a positive number if "Tom" is located and a 0 if it is not. For the IIf function, 0 means false (so it will return a No to the flag field) and any other number means true (it will return a Yes to the flag field). So our formula will return "Yes" as long as "Tom" is found somewhere in the Resource Names field (see Figure B).

 Figure B
 

The Bar Style

Now that we have a flag field testing for Tom, we only have to add a new Bar Style to show which tasks are assigned to Tom. Here are the steps to add this particular Bar Style:

1.      Choose Format, Bar Styles (or right-click in the graphics area and choose Bar Styles)

2.      Select the Normal Task Bar Style and click on Cut and then twice on Paste (since you have no Copy Button available here!)

3.      Since the bars are drawn in the order they are listed and you'll want Tom's bars to be drawn last (over the standard bar), select the lower bar to show Tom's assignments.

4.      Change the title to "Tom's Tasks" (or whatever) and change the "Show for … Tasks" from "Normal" to "Flag1".

5.      Modify the bar appearance as you wish. Here I used the lower half-bar shape to keep the main task bar visible.

Here is the result:

Figure C

More…

Now you can hide the Flag1 column ("Tom Test") and forget it, as it will always show the special bar for all tasks that Tom is assigned to.

There are 20 custom flag fields that you can use, so you can identify assignments for up to 20 resources. You can use fields other than the Resource Names field to test for the resource assignment.  In fact, Resource Group and Resource Initials are even better to use than Resource Names. They are automatically populated with text from the resource Group and Initials fields for the assigned resources (just as the Resource Names field is populated with the text in the resource's Name field). But, whereas you typically want to use standard names in the Name field you can type code-like text into the Group or Initials fields for resources. Therefore you can create unique codes for each resource to help avoid mistaken matches like "Tom" equals "Thomas".

 Back to Project Management

 

[Home] [About Us] [Services] [Events] [Register] [search] [Contact us] [Members] [Web board]