IIf formula in microsoft project custom field

Copper Contributor

I added the following custom field with the formula: [Remaining Work] / [Remaining Duration]


Now I want to add an "if" condition, meaning if a task is 100% complete, that no value or the value "n/a" is given.


I found the IIf function is the correct one, but I only get errors with the different ways I have tried to write the formula, e.g.: IIf ([% Complete] = 100, "n/a", [Remaining Work] / [Remaining Duration]) or

IIf ([% Complete] <100, ([Remaining Work] / [Remaining Duration]), "n/a")


Do you have any advise how to use the IIf formula?

10 Replies
Nicol860 --

To create a formula that works correctly, I recommend that you use a custom Text field. That is because you want the "n/a" text to appear when a task is 100% complete. Also, you need the formula to test for a milestone, as the formula will result in a division by 0 error. Following is the updated formula, which I tested and confirmed that it works correctly in a Text field:

IIf([Milestone],"n/a",IIf([% Complete]=100,"n/a",[Remaining Work]/[Remaining Duration]))

Hope this helps.

Dear @Dale Howard, thank you very much for your help!

Unfortunately I can't get it to work, but do you know some resources (books, websites etc.) where I can learn more about how to write formulas in MS Project? I can't find much information online, does there just not exist much information? 


Thank you very much for your help! 

Kind regards,


Nicola -- "Unfortunately I cannot get it to work..." does not give us enough information to help you further. Did you copy and paste my formula into a task Text field? If so, the formula should have worked immediately. What did you do in response to my last message? And if it is generating an error, please include one or more screenshots to show us what you see.

Also, to the best of my knowledge, the only book on Microsoft Project formulas is in Portuguese, and was written by a colleague of mine. Do you speak/read Portuguese? :)

@Dale Howard,
Ismet Kocaman has a book on Project formula creation. It's not free and I don't know the price but I believe it is similar to Rod Gill's book on Project VBA. The link for Ismet's book is:


@Dale Howard Yes, I copied your formula and also tried typing it in and picking the fields & operators, but it gives me an error message (see screenshot attached).


The difficulty is that it does not indicate where the error is, I tried if a simple IIf formula works, but not even that I can get to work.


So far only the formula [Remaining Work]/[Remaining Duration] has worked on its own (as a number type).


With the IIf formula I want to achieve that the project managers see when a task is complete, so they don't need to pay attention to these tasks when they assess how much work still is to be done in the remaining time for a task. So it does not necessarily need to show "n/a" it could also show something else (like a number or a flag)

I have a different user name because I switched to my work computer
Nicola -- Thanks for sharing the screenshot. That DOES help. I just tested my formula in Project Online Professional (the M365 version of Microsoft Project) and it does work as designed. Therefore, I would recommend you do the following:

1. Launch Microsoft Project and connect to your Project Online system.
2. Open a project that is in flight. You do not need to check out the project.
3. Click Project > Custom Fields.
4. Select the first available task Text field and rename it to the field name of your choice.
5. Click the Formula button for the new Text field.
6. Copy the formula from my previous post in this forum, and then paste it into the Formula dialog.
7. Click the OK button. You SHOULD NOT get an error at this point.
8. In the Custom Fields dialog, click the Add Field to Enterprise button.
9. In the Add Field to Enterprise dialog, DO NOT change the name of the field. Leave the name as it currently appears and then click the OK button. You should see a confirmation that the field was added successfully to Project Web App.
10. Click the OK button to close the confirmation dialog and then click the OK button to close the Custom Fields dialog.
11. Launch your preferred web browser and then navigate to your organization's Project Web App.
12. In the upper right corner of the page, click the Settings button (it looks like a gear wheel) and then select the PWA Settings item.
13. On the PWA Settings page, click the Enterprise Custom Fields and Lookup Tables link.
14. On the resulting page, click the name of the new Text field you just imported.
15. Remove the text that is inside of the parentheses characters, along with the parentheses characters, such as (Text1) for example.
16. Click the Save button.

Completing the above process should resolve your problems. Let us know if this works.

Thank you @Dale Howard ! It worked perfectly! Thank you very much for your step by step instructions!


Do you also know how I can adjust the formula so the summary tasks and parent tasks have an "n/a" as well? (on the picture these are the bold tasks "Phase 1" and "Planungsphase 1")





NickkyE2404 --

Sure do. Open the project in question, then display the Custom Fields dialog. Select the custom Text field in which you created the formula. In the Calculation for Task and Group Summary Rows section of the dialog, select the Use Formula option. Click the OK button. Hope this helps.
Thank you John, for your support. I appreciate it very much.