using formulas ms project

Forum home » Delegate support and help forum » Microsoft Project Training and help » Using Formulas in MS Project

Using Formulas in MS Project

resolvedResolved · High Priority · Version 2010

Using Formulas in MS Project

Please provide how to approach using formulas in Project, e.g. using IIf in Project and explain the difference between Excel formulas and Project.

Please explain the formula below:

IIf([% Complete]<100,Switch(([% Complete]=0 And (DateValue([Current Date])-DateValue([Start]))>0),1,((DateValue([Current Date])-DateValue([Finish]))<-5),3,(DateValue([Current Date])-DateValue([Finish]))>=-5 And (DateValue([Current Date])-DateValue([Finish]))<0,2,(DateValue([Current Date])-DateValue([Finish]))>=0,1),3)

RE: Using Formulas in MS Project

Hello Ajibola,

Thank you for your question regarding working with formulas in Project. Your question is outside of the scope of Project Introduction / Intermediate. We do run an advanced course where we introduce custom fields using formulas.


If you require further assistance, please reply to this post. Or perhaps you have another Microsoft Office question?

Have a great day.
Regards,

Rodney
Microsoft Office Specialist Trainer

RE: Using Formulas in MS Project

Hi Rodney,

I did the Introduction/Intermediate as well as The Advanced MS Project 2010. I was asked to ask questions regarding formulas any-time. I do know that this is within the scope of the Advanced course I did.

Ajibola.

RE: Using Formulas in MS Project

Hello Ajibola,

My apologies, I had to check with our admin team who confirmed you had completed the advanced course. It doesn't show up in the courses attended location in the forum post.

To answer your first question as to what approach to use when working with formulas in Project and the difference between Excel formulas and those of Project will revolve around what you would like to achieve.

For example, if you require to use a graphical indicator to show the status of the completeness of each task, you must first decide what parameters to use, then create a custom formula field using appropriate functions such as Iif which incorporate your chosen parameters. Then set the graphical indicators which match the results of your formula... then add the new custom field to a table and make sure that the results are what you are looking for.

Writing formulas in Project and Excel is fairly similar, however, the syntax may differ. When using Iif the syntax within the brackets is (Expression, True Part, False Part) pretty much the same as Excel.

To explain the formula above it is easier if you separate it into lines... 1 for each action. The formula begins with Iif then is followed by the Switch function. The Switch function syntax is as follows: Switch(Expression1,value1,expression2,value2...)etc.

Shown on separate lines the formula goes like this:

IIf([% Complete]<100,

Switch(([% Complete]=0 And (DateValue([Current Date])-DateValue([Start]))>0),1,

((DateValue([Current Date])-DateValue([Finish]))<-5),3,

(DateValue([Current Date])-DateValue([Finish]))>=-5 And (DateValue([Current Date])-DateValue([Finish]))<0,2,

(DateValue([Current Date])-DateValue([Finish]))>=0,1),3)

You will notice that number 1 or 2 or 3 appear in the formula as values after the expression calculation. These numbers represent the result you are looking for if the above parameters are true. If none of them are true the final result is a 3 (which is also the same as the second Switch expression).

You can now use these numbers when setting graphical indicators... Equals > 1 > Green
Equals > 2 > Yellow
Equals > 3 > Red

...or what ever choices you make.

You will also notice in the formula that the function DateValue is used. The syntax is DateValue(Date). The fields that have been used in the formula are Current Date, Start and Finish.

Examine the formula closely and you will be able to analyse it.

I hope this resolves your question. If it has, please mark this question as resolved.

If you require further assistance, please reply to this post. Or perhaps you have another Microsoft Office question?

Have a great day.
Regards,

Rodney
Microsoft Office Specialist Trainer

Attached files...

Project.zip

RE: Using Formulas in MS Project

Hi Rodney,

What is Switch? what is the difference between Iif and Switch?
Could you also explain the brackets, such as when is one bracket required or when 2 is required. ( (( (((?

Is there any further course on MS Project formulas that I can do? I know how to copy formulas and use but I'd like to come up with my formulas.

Thanks,
Ajibola.

RE: Using Formulas in MS Project

Hello Ajibola,

Let me deal with your first question... What is Switch?

First of all, you should by now be familiar with the term 'syntax' which is the settings of a function always starting with the function name, then followed by an opening bracket, then by the arguments separated by a comma (which will be different for each function) then finally followed by a closing bracket.

In my answer above I gave you the syntax of the switch function which is as follows:

Switch(Expesssion1,Value1,Expression2,Value2...etc.) i.e. Evaluates a list of expressions and returns a Variant value or an expression associated with the first expression in the list that is True.

The Iif function has its own syntax which of course will be different to Switch. This I gave in my first answer to you... check it out. Iif works on the same principle as an IF function in Excel.

The formula you gave me, uses an Iif first, followed by the Switch function with several expressions. If none of the Switch expressions are true, then right at the end we place the result. This is the last part of the Iif function.

If you do not need the false result at the end, then simply use the Switch function without an Iif.

As far as brackets are concerned, you are always reminded of the order in which formulas are calculated

Brackets first
Exponential second
Multiplications & Divisions third
Additions & Subtractions fourth...

... so depending in what order you require the formula to calculate things you may have to add additional brackets. If you add an opening bracket you must at some point in the formula put a closing bracket. All functions have an opening bracket right after the name followed by the arguments then a closing bracket at the end.

I suggest buying a few books on how to construct formulas and learn more on the basic techniques, then applying these in your own environment.

We do not run any further courses on Project, however, we do provide consulting services which you are welcome to inquire about.

I hope this resolves your question. If it has, please mark this question as resolved.

If you require further assistance, please reply to this post. Or perhaps you have another Microsoft Office question?

Have a great day.
Regards,

Rodney
Microsoft Office Specialist Trainer

RE: Using Formulas in MS Project


dear ALL

i have some problems with MS project 2010 Switch Formula
did switch have max of Exprision ????? just i add more that 14 exp error Messege appear that formula is worng ???

waiting your replay ASAp


 

MS Project tip:

MS Project 2010 Scroll to Task

Ever feel lost on a large project file? In Gantt view, Task ribbon, Editing, click on the Scroll to Task tool to centre the task bar on your screen.

Shortcut Ctrl+Shift+F5

Same as Go to Selected Task in MS Project 2003.

View all MS Project hints and tips


Server loaded in 0.06 secs.