Vous êtes sur la page 1sur 18

Quest-ce quun champ personnalis ?

Les champs personnaliss contiennent les informations et les valeurs que vous devez/voulez afficher dans votre
projet et qui sont propres votre organisation. Ils peuvent renfermer des formules incorporant des champs Project
existants ainsi que dautres champs personnaliss, en vue de calculer des donnes. Ils peuvent aussi renfermer
des indicateurs graphiques vous avertissant de la satisfaction de telle ou telle condition.
Les valeurs des champs personnaliss et les valeurs des indicateurs graphiques dans Microsoft Project 2010
peuvent donc tre calcules laide de formules, mais cest--dire ? Comment crire cette formule ?
Dans MS Project 2010, cliquez sur le menu Projet puis Champs personnaliss dans la zone Proprits
ou alors effectuez un right-click dans la zone des titres des colonnes (affichage mode Diagramme de Gantt) et
cliquez sur Champs personnaliss .

Ma formule en franais
Dans mon cas prcis, pour un projet donn, voici les valeurs que je souhaitais afficher gauche de mon
diagramme de Gantt : un statut de chacune de mes tches (seulement le niveau le plus fin) et lidentification des
jalons.
En franais, voici ce que je voulais que ma formule calcule automatiquement :

Si lavancement dune tche est de 100%, alors le statut devait tre Achev .
Sinon : lavancement de la tche est < 100%. Dans ce cas :
si la date prvisionnelle de fin est passe (infrieure ou gale la date

daujourdhui), alors le statut devait tre En retard


sinon, la date prvisionnelle de fin nest pas encore passe (strictement suprieure
la date daujourdhui). Dans ce cas :

Si la date prvisionnelle de dbut nest pas encore passe (suprieure ou


gale aujourdhui) :

si lavancement est > 0%, alors le statut devait tre En avance

sinon, lavancement est = 0%. Dans ce cas :

soit la date prvisionnelle de dbut est dans 7 jours ou

moins (infrieure ou gale la date daujourdhui +7) alors le statut devait tre
Dmarrage imminent
soit la date prvisionnel de dbut est dans plus de 7 jours
(strictement suprieure la date daujourdhui + 7) alors le statut devait tre
Dmarrage > 7 jours
Sinon, la date prvisionnelle de dbut est passe (strictement infrieure

aujourdhui). Dans ce cas :

si la dure = 0%, alors le statut devait tre Jalon

sinon, la dure 0% (il sagit donc dune tche et non dun jalon).
Dans ce cas :

si lavancement temporel est infrieur lavancement du


travail alors le statut devait tre En cours

sinon, lavancement temporel est suprieur lavancement

du travail alors le statut devait tre Risque de retard .

Ladite formule dans MS Project


La calcul de lavancement temporel se calcule de la manire suivant :
Avancement Temporel = (date daujourdhui date prvisionnelle de dbut) / (date prvisionnelle de fin date
prvisionnelle de dbut).
En traduisant le prcdent paragraphe en langage MS Project et en incorporant la formule ci-dessus, on obtient le
texte suivant copier-coller dans MS Project :
Switch((([%

Travail

achev]<100)

achev]=100)

And

([Fin]<=(Date())));En
([Dbut]<=(Date()))

And

([Dure]>0));Achev;([Dure]=0);Jalon;(([%

([Fin]<=(Date())));En

retard;(([%

retard;(([%

achev]<100)

And

Travail

([Dure]>0))

And

Travail

Travail

achev]<100)

And

And

([Fin]>(Date()))

And

((((Date())-[Dbut])/([Fin]-[Dbut]))<[%

Travail

achev]);En cours;(([% Travail achev]<100) And ([Fin]>(Date())) And ([Dbut]<=(Date())) And


([Dure]>0)) And ((((Date())-[Dbut])/([Fin]-[Dbut]))>=[% Travail achev]);Risque de retard;(([%
Travail achev]<100) And ([Fin]>(Date())) And ([Dbut]>(Date())) And ([% Travail achev]>0));En
avance;(([% Travail achev]<100) And ([Fin]>(Date())) And ([Dbut]>(Date())) And ([% Travail
achev]=0)) And ((Date())>=([Dbut]-7));Dmarrage imminent;(([% Travail achev]<100) And
([Fin]>(Date())) And ([Dbut]>(Date())) And ([% Travail achev]=0)) And ((Date())<([Dbut]7));Dmarrage > 7 jours)
Remarque : attention bien vrifier que vos-enttes de colonnes soient bien retranscrits dans la formule, sinon
vous obtiendrez invariablement le rsultat #ERROR dans chacune de vos lignes ! Par ailleurs, WordPress me
remplace mes guillemets droits par des guillemets la franaise Du coup jai remplac mes
guillemets droits par des guillemets langlaise, mais ceux-ci ne sont pas lisibles non plus par MS
Project. Il faut faire un Ctrl+H et remplacer tous les guillemets langlaise par des guillemets droits
(ceux situs en dessous du chiffre 3 sur le clavier.
Si certains dentre vous lecteurs possdez des formules magiques du genre, et que vous souhaitez les partagez :
nhsitez pas utiliser le champs commentaire en bas de larticle ! ;-)

Rfrences et pour aller plus loin


http://msdn.microsoft.com/fr-fr/library/ee767700.aspx
http://office.microsoft.com/fr-fr/project-help/explorer-les-avantages-lies-aux-champs-personnalisesdans-votre-projet-HA001020286.aspx

2 rflexions sur Comment crire les formules dans les


champs personnaliss de MS Project ?

1.

Merci pour la formule. Pour ceux qui ont comme moi MSP en version US, en voici la traduction:
Switch((([% Work Complete]=100) And ([Duration]>0)),Finished,([Duration]=0),Milestone,(([%
Work

Complete]<100)

And

([Finish]<=(Date()))),'Late',(([%

Work

Complete]<100)

And

([Finish]<=(Date()))),'Late',(([% Work Complete](Date())) And ([Start]0)) And ((((Date())-[Start] )/


([Finish]-[Start] ))<[% Work Complete] ),'On going',(([% Work Complete] (Date())) And ([Start] 0))
And ((((Date())-[Start] )/([Finish]-[Start] ))>=[% Work Complete] ),Risk of delay,(([% Work
Complete](Date())) And ([Start]>(Date())) And ([% Work Complete]>0)),In advance,(([% Work
Complete](Date())) And ([Start]>(Date())) And ([% Work Complete]=0)) And ((Date())>=([Start]
-7)),Starts soon,(([% Work Complete](Date())) And ([Start]>(Date())) And ([% Work Complete]=0))
And ((Date())<([Start] -7)),'Starts within 7 days')

MS project doesn't have a field to compute the planned percentage of completion! MS Project
has BCWS which is similar to my request, but it will not compute the planned percentage of
completion for those tasks that has no cost, no resources assigned. My request is very simple;
if I have many tasks in my project (some with assigned cost and others with no cost), at any
time I want to know (on the task level and on the project level) what is the planned
percentage of completion regardless of the cost.
Example;
If I have a project with the following tasks:
Name Duration Sdate
Edate
T1
10
01-01-07 10-01-07
T2
10
11-01-07 21-01-07
T3
20
01-03-07 20-03-07
If I save this baseline,I need a field (planned Percentage completion)to have the following
values:
if the status date is:
10-01-07 -----> planned Percentage completion should show 25%
21-01-07 -----> planned Percentage completion should show 50%
28-01-07 -----> planned Percentage completion should show also 50%

15-02-07 -----> planned Percentage completion should show also 50%


28-02-07 -----> planned Percentage completion should show also 50%
20-03-07 -----> planned Percentage completion should show also 100%

IIf([Baseline Start]>[Status Date],0,IIf([Baseline Finish]<[Status


Date],100,projdatediff([Status Date],[Baseline Start],IIf([Task Calendar]="None",[Project
Calendar],[Task Calendar]))*100/projdatediff([Baseline Finish],[Baseline Start],IIf([Task
Calendar]="None",[Project Calendar],[Task Calendar]))))

Creating a custom field to indicate if a task


finish date is later than specific date.
KSmith asked Jul 6, 2011 | Replies (4)

I need help creating a custom field formula that will provide a Red/Yellow/Green indication of a
task based on if the Finish Date is later than a set date, in this case July 22 2011. This date will
change on a monthly basis.
Parameters:
Finish date > the set date, i.e. 2011-07-22 - indicator green
Finish date = the set date, i.e. 2011-07-22 indicator yellow
Finish date = < the set date, i.e. 2011-07-11 indicator red
Any task that is 100% complete will indicate blue
Thanks in advance!
Join this group

4 Replies
0

kswarm replied Jul 6, 2011

KSmith,
This formula will need a little adaption based upon your specific needs, but it may do the trick. I
use it in projects to provide a quick view of tasks on the gantt. It's makes it easy to see what is
past due. I create a new column as "Text 1" and renamed it "Past Due" and use the following
formula. The formula includes reference to another column "text 2" renamed as "Critical Path"
which allows an over-ride for items not on the critical path which turns the icon blue rather than
red, green or yellow.
I am not the author, but have been able to adapt it when needed.
Formula for "Past Due" column in MS Project
Switch(Finish<date() And [% Complete]<100 And [Text2]="Yes" Or Finish<date() And [%
Complete]<100 And [Text2]="","Yes",Finish<date () And [% Complete]<100 And
[Text2]="No","NCP",Finish<(d ate()+7) And [% Complete]<85,"Maybe",Finish<(date( )+7) And [%
Complete]>=85,"No",[% Complete]=100,"No",Finish>(date()+7), "No")
Good luck
Keith
0

Graham McHardy replied Jul 6, 2011

Hello K. As with almost everything Project, there are several ways to do this. Here's one:
Configure a custom duration field with a formula like this:
IIf([% Complete]=100,-99*480,DateDiff("d",[Status Date],[Finish])*480)
The advantage of a duration field is that tooltips show the value in days.
Here I've used the Status Date as the set date. If you're using Project Server and you want the
same date for all projects, you would use an enterprise date field for the set date - set this with a
formula that you change every month.
If you're using the Status Date differently, then you could use a local custom date field for the set
date.
The indicators look like this:
equals -99d 8
greater than 0d 1
equals 0d 2
less than 0d 3

Graham
0

Darryl Del Rio replied Jul 6, 2011

Here is a formula I use in my Project Plans. This customized text fields 10, 11 and 12 but you can
use any 3 fields, With a little modification you could probably add the Blue indicator you want.
Go to custom Fields and choose Text as the type
Text formula field 10
IIf(([% Complete]<100),0,100)
Text formula field 11
Switch(([Scheduled Finish]>([Current Date]+7)),0,([Scheduled Finish]<[Current Date]) Or
([Scheduled Finish]=[Current Date]),1,([Scheduled Finish]>[Current Date]) And ([Scheduled
Finish]<([Current Date]+8)),2)
Text formula field 12
[Text10]-[Text11]
Click Graphic Indicator
Click Insert Row
Test equals Value(s) -1 select Red image indicator
Add row
Test equals Value(s) -2 Select Yellow image indicator
Add row
Test is greater than or equal to Value(s) 0 Select Green image indicator
Add a Column to your plan and select Text 12, rename it to Status.
When the finish date is within 7 days the indicator will turn yellow
If the % complete is not 100% on finish date the indicator will turn Red

MS Project how to compare % Complete with Planned


% Complete
up

I need to have a column to show Planned % Complete for a certain date that I will compare

vote down with % Complete column.


vote
favorite

Now % Complete formula is


cstr(IIf([Duration]=0,0,100*[Actual Duration]/[Duration])) & " %"

customize Planned % Complete formula that I make is


cstr(IIf([Duration]=0,0,100*ProjDateDiff([Start],[Status Date])/[Duration])) & " %"

both formulae give me exactly same result but at task level only. However, the later one does
not give correct result at summary level if I use use formula for roll-up.
I am really struggling with this, would appreciate your help. Or should I entirely follow
different approach.

IIf(ProjDateDiff(Start,[Status Date])/480>=Val(ProjDurConv([Baseline
Duration],pjDays)),Val(ProjDurConv([Baseline Duration],pjDays)),IIf(DateDiff(d,[Baseline Start],
[Status Date])<=0,0,ProjDateDiff(Start,[Status Date])/480))

Saurabh Sood says:


5 November, 2014 at 12:58 pm

Hi Niks,
This is a very nice tutorial and makes life easier for a project manager.
I still have a querie;1) The Planned % does not show for a phase.It only shows for indended
tasks but not a phase where they are indented to.
Appreciate your help and looking ahead for a reply!
Regards,
Saurabh Sood
Reply

niksprojects says:

9 November, 2014 at 10:17 pm

IIf(ProjDateDiff(Start,[Status Date])/480>=Val(ProjDurConv([Baseline
Duration],pjDays)),Val(ProjDurConv([Baseline Duration],pjDays)),IIf(DateDiff(d,[Baseline Start],
[Status Date])<=0,0,ProjDateDiff(Start,[Status Date])/480)) Use this formula and see if it
resolves your issue.

IIf(ProjDateDiff(Start,[Status Date])/480>=Val(ProjDurConv([Baseline
Duration],pjDays)),Val(ProjDurConv([Baseline Duration],pjDays)),IIf(DateDiff(d,[Baseline Start],
[Status Date])<=0,0,ProjDateDiff(Start,[Status Date])/480)) Use this formula in STEP 02 to
calculate elapsed days only considering working days.

IIf([Dbut (planifi)]>[Date d'tat];0;IIf([Fin (planifie)]<[Date d'tat];100;projdatediff([Date


d'tat];[Dbut (planifi)];IIf([Calendrier des tches]="Aucun";[Calendrier du projet];
[Calendrier des tches]))*100/projdatediff([Fin (planifie)];[Dbut (planifi)];IIf([Calendrier
des tches]="Aucun";[Calendrier du projet];[Calendrier des tches]))))

Calcul % Prvu
IIf([Dbut (planifi)]>[Date d'tat];0;IIf([Fin (planifie)]<[Date d'tat];100;projdatediff([Date
d'tat];[Dbut (planifi)];IIf([Calendrier des tches]="Aucun";[Calendrier du projet];
[Calendrier des tches]))*100/projdatediff([Fin (planifie)];[Dbut (planifi)];IIf([Calendrier
des tches]="Aucun";[Calendrier du projet];[Calendrier des tches]))))

Calcul de dure
Travailler avec plusieurs calendrier de diffrentes heures par jour
IIF([Task Calendar]="24 Hours per Dat"[Scheduled Duration*0.33,[Scheduled Duration])

The code below will set flag7 to true if there are no incomplete predecessors, and
flase if any incomplete predecessors are found:
Sub GetPredStatus()
Dim pj As Project
Dim t As task 'subject task
Dim p As task 'Predecessor task
Set pj = activeProject
For Each t In activeProject.Tasks
If t Is Nothing Then GoTo NextTask
For Each p In t.PredecessorTasks
If p.percentComplete < 100 Then
t.Flag7 = False
GoTo NextTask
End If
Next p
t.Flag7 = True
NextTask:
Next t
End Sub

The code below will set flag7 to true if there are no incomplete predecessors, and
flase if any incomplete predecessors are found:
Sub GetPredStatus()
Dim pj As Project
Dim t As task 'subject task
Dim p As task 'Predecessor task
Set pj = activeProject

For Each t In activeProject.Tasks


If t Is Nothing Then GoTo NextTask
For Each p In t.PredecessorTasks
If p.percentComplete < 100 Then
t.Flag7 = False
GoTo NextTask
End If
Next p
t.Flag7 = True
NextTask:
Next t
End Sub

Task indicator. All Predecessor


tasks are complete y/n,
true/false
Project
,
Project Server
>
Project Customization and Programming
Question

0
Sign in to vote

I would be most grateful if someone could provide a complete solution that would allow
me to create a task field that would indicate if all predecessor tasks are complete or not.
This would allow me to do some desperately needed filtering. MS-Project 2010.

Thanks in advance,
J
Wednesday, October 10, 2012 2:59 AM
Reply
|
Quote

JayDove78
0 Points

Answers

0
Sign in to vote

Hello J,
The code below will set flag7 to true if there are no incomplete predecessors, and flase
if any incomplete predecessors are found:
Sub GetPredStatus()
Dim pj As Project
Dim t As task 'subject task
Dim p As task 'Predecessor task
Set pj = activeProject
For Each t In activeProject.Tasks
If t Is

Nothing Then GoTo NextTask

For Each p In t.PredecessorTasks


If p.percentComplete <
t.Flag7 =

False

GoTo NextTask
End If
Next p
t.Flag7 =
NextTask:
Next t
End Sub

True

100 Then

Edited by Andrew Simpson Wednesday, October 10, 2012 8:55 AM

Proposed as answer by Andrew Simpson Thursday, October 11, 2012 3:16 PM

Marked as answer by JayDove78 Saturday, October 20, 2012 5:45 PM


Wednesday, October 10, 2012 8:35 AM
Reply
|
Quote

Andrew Simpson
Eversight Ltd
(Partner)
1,445 Points

All replies

0
Sign in to vote

Hello J,
The code below will set flag7 to true if there are no incomplete predecessors, and flase
if any incomplete predecessors are found:
Sub GetPredStatus()
Dim pj As Project
Dim t As task 'subject task
Dim p As task 'Predecessor task
Set pj = activeProject
For Each t In activeProject.Tasks
If t Is

Nothing Then GoTo NextTask

For Each p In t.PredecessorTasks


If p.percentComplete <
t.Flag7 =

False

GoTo NextTask
End If
Next p
t.Flag7 =

True

100 Then

NextTask:
Next t
End Sub

Edited by Andrew Simpson Wednesday, October 10, 2012 8:55 AM

Proposed as answer by Andrew Simpson Thursday, October 11, 2012 3:16 PM

Marked as answer by JayDove78 Saturday, October 20, 2012 5:45 PM


Wednesday, October 10, 2012 8:35 AM
Reply
|
Quote

Andrew Simpson
Eversight Ltd
(Partner)
1,445 Points

0
Sign in to vote

This is terrific. Thanks so much. A few follow-up questions...


Will this macro go through all tasks in the project and set an indicator for each task (to
indicate if all predecessor tasks related to the task are complete or not)?
Will the indicator be based on all predecessor tasks regardless where the predecessor
task resides in the project plan?
Thursday, October 11, 2012 12:32 AM
Reply
|
Quote

JayDove78
0 Points

0
Sign in to vote

Andrew,

Using "GoTo" is a little archaic. Instead you could simply say "Exit For" to jump out of
the inner loop once you found a predecessor that is not complete.
To avoid blank rows, (although I don't think you can even have a blank task row in
Project 2010), the shorter version is:
"If Not t is Nothing Then"
John
Thursday, October 11, 2012 2:06 AM
Reply
|
Quote

John - Project
14,805 Points

0
Sign in to vote

Thanks John,
"Exit For" isn't something I've used before, but I can see the logic in it, thanks for the
tip.
Wouldn't work in this case though as I needed to exit the for/next loop and skip
the t.flag7 = true statement immediately after the loop.
Good tip on the if statement too, thanks again.
Thursday, October 11, 2012 8:38 AM
Reply
|
Quote

Andrew Simpson
Eversight Ltd
(Partner)
1,445 Points

Sign in to vote

Hi Jay
>>Will this macro go through all tasks in the project and set an indicator for each task
(to indicate if all predecessor tasks related to the task are complete or not)?
Yes
>>Will the indicator be based on all predecessor tasks regardless where the
predecessor task resides in the project plan?
Yes
Thanks,
Andrew
Thursday, October 11, 2012 8:39 AM
Reply
|
Quote

Andrew Simpson
Eversight Ltd
(Partner)
1,445 Points

0
Sign in to vote

Andrew,
You're welcome. With regard to setting the flag to true, I normally set a variable, in this
case Flag7 to my desired state before I enter a loop. Then if the loop criteria is met, the
flag is set to false. So yes, you can use the Exit For.
On the other hand you could also restructure the code based on the fact that by
default, all extra flag fields are false. Then you would reverse the logic and set the flag
true if all predecessors are 100%.
Just another thought.
John
Friday, October 12, 2012 2:54 AM

Reply
|
Quote

John - Project
14,805 Points

0
Sign in to vote

Andrew,
Thank you for your time. This was very helpful. I can't imagine I'm the only person
that finds this useful. I wonder if a similar indicator will ever be included a future
release.
Thanks again,
J
Saturday, October 20, 2012 5:47 PM
Reply
|
Quote

JayDove78
0 Points

0
Sign in to vote

yeah I see where you are coming from on the inner-most Goto since you want to kick
out of the Precdecssor loop as soon as you find ANY predecessor that is not complete.
As for the first one it is just a matter of preference.
I tend to go for this basic loop structure for all task and resource collection loops:
For each T in Activeproject.Tasks
If NOT (T is Nothing) then

End if
Next T

Brian Kennemer - Project MVP


DeltaBahn Senior Architect
endlessly obsessing about Project Serverso that you dont have to.
Blog | Twitter | LinkedIn