SOLVED

How to Display Blank field using custom field

%3CLINGO-SUB%20id%3D%22lingo-sub-2239803%22%20slang%3D%22en-US%22%3EHow%20to%20Display%20Blank%20field%20using%20custom%20field%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2239803%22%20slang%3D%22en-US%22%3E%3CP%3EHi%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHave%202%20questions%20with%20regard%20to%20Ms%20Project%20custom%20field%20usage.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CFONT%20size%3D%224%22%20color%3D%22%230000FF%22%3E%3CSTRONG%3E1.%3C%2FSTRONG%3E%3C%2FFONT%3E%20I%20have%20a%20very%20simple%20question%20but%20I%20don't%20seem%20to%20be%20able%20to%20get%20it%20right.%3C%2FP%3E%3CP%3EI%20am%20trying%20display%20a%20blank%20field%20on%20a%20new%20custom%20column%20of%20type%20number%20using%20custom%20field.%26nbsp%3B%20Below%20is%20the%20formula%20I%20am%20using%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIIf((%5BBudget%20Cost%5D%26lt%3B%26gt%3B%22%22)%2CRound((%5BBudget%20Cost%5D%2F186000)*100)%2C%22%22)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20am%20checking%20the%20Budget%20Cost%20col%20and%20if%20is%20not%20empty%20then%20do%20the%20maths%20shown%20about%20basically%20finding%20some%20percentage%20value%20and%20rounding%20the%20final%20number.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20Budget%20Cost%20is%20empty%2Fblank%20then%20I%20just%20want%20to%20leave%20it%20blank%20as%20well%20do%20nothing%20with%20it.%26nbsp%3B%20So%20for%20the%20false%20part%20I%20simply%20said%20%22%22%20it%20gave%20an%20error%20showing%20%23ERROR%20I%20guess%20why%20this%20so%20-%20because%20the%20new%20custom%20field%20is%20of%20a%20type%20number%20and%20I%20am%20trying%20to%20store%20an%20empty%20string.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESo%20I%20even%20replace%20the%20false%20part%20with%20%5BBudget%20Cost%5D%20meaning%20if%20it%20is%20empty%20just%20copy%20the%20empty%20field%20into%20my%20new%20custom%20col.%20Still%20it%20gave%20me%20%23ERROR%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20tried%20replacing%20with%20NULL%20also%20did%20not%20work.%20For%20now%20I%20have%20replace%20the%20false%20part%20with%20number%200%20and%20it%20work%20fine%20but%20I%20have%200%20displayed%20for%20those%20Budget%20Cost%20cells%20with%20blank%20field.%20This%20is%20very%20ugly%20and%20I%20dont%20like%20this.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20just%20want%20to%20display%20an%20empty%20field%2F%20blank...How%20do%20I%20that%2C%26nbsp%3B%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CFONT%20size%3D%224%22%20color%3D%22%230000FF%22%3E%3CSTRONG%3E2%3C%2FSTRONG%3E%3C%2FFONT%3E.%20Also%20one%20side%20question%20how%20do%20a%20get%20sum%20of%20a%20row%20of%20numbers...at%20the%20moment%20as%20u%20can%20see%20in%20my%20formula%20I%20am%20manually%20inserting%20the%20sum%20of%20the%20Budget%20Cost%20column%20as%26nbsp%3B%20%24186%2C000%20to%26nbsp%3B%20get%20my%20percentages.%20Is%20there%20a%20function%2C%20built%20in%20field%20etc%20that%20I%20can%20use%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAny%20help%20my%20appreciated.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ERgds%3C%2FP%3E%3CP%3EKR%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2239803%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EProject%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EProject%20Desktop%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2239965%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20Display%20Blank%20field%20using%20custom%20field%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2239965%22%20slang%3D%22en-US%22%3E%3CP%3EWell%2C%20you're%20right%20in%20that%20the%20error%20occurs%20because%20you%20are%20trying%20to%20write%20a%20string%20(%22%22)%20into%20a%20custom%20Number%20field.%20However%2C%20even%20if%20you%20change%20the%20formula%20to%20write%20a%20zero%2C%20the%20end%20result%20will%20ALWAYS%20be%20zero%20because%20the%20Budget%20Cost%20field%20is%20only%20applicable%20to%20the%20Project%20Summary%20task%20so%20no%20task%20field%20will%20ever%20have%20a%20budget%20cost.%20You%20cannot%20show%20a%20%22blank%22%20in%20a%20Number%20field%2C%20but%20you%20can%20use%20a%20Text%20field%20to%20show%20nothing.%3CBR%20%2F%3E%3CBR%20%2F%3EOn%20your%20second%20question%2C%20you%20can%20get%20the%20sum%20of%20a%20row%20of%20numbers%20by%20creating%20a%20custom%20field%20that%20is%20the%20sum%20of%20each%20element%20in%20the%20row%20(e.g%2C%20Number1%20%2B%20Number2%20%2B%20etc.).%20However%2C%20I%20think%20what%20you%20perhaps%20are%20asking%20is%20how%20to%20get%20the%20sum%20of%20a%20column%20of%20numbers%20(e.g.%20sum%20up%20the%20Number1%20field).%20For%20the%20latter%2C%20you%20simply%20check%20the%20option%20%22Calculation%20for%20task%20and%20group%20summary%20rows%22%20and%20select%20%22sum%22%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2240044%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20Display%20Blank%20field%20using%20custom%20field%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2240044%22%20slang%3D%22en-US%22%3EHi%20John%3CBR%20%2F%3EThank%20you%20for%20your%20prompt%20reply.%20Appreciate%20your%20response.%3CBR%20%2F%3E%3CBR%20%2F%3E1.%20I%20agree%20Budget%20Cost%20can%20only%20be%20applied%20to%20the%20Project%20summary.%20But%20what%20I%20have%20done%20is%20that%20I%20created%20a%20Table%20based%20on%20Resource%20Usage%20and%20in%20that%20table%20I%20have%20a%20Budget%20Cost%20col%20which%20displays%20all%20the%20Budget%20cost%20for%20each%20resource%20item.%20However%20some%20cells%20in%20this%20column%20can%20be%20blank.%20Then%20I%20created%20a%20custom%20field%20to%20calculate%20the%20percentages%20based%20on%20my%20earlier%20formula%20I%20showed.%20That's%20where%20my%20question%20is%20about%20for%20those%20blank%20cells%20I%20want%20to%20ignore%20calculating%20the%20percentage.%3CBR%20%2F%3E%3CBR%20%2F%3E2.%20Yes%20I%20am%20asking%20for%20the%20sum%20of%20numbers%20in%20a%20column.%20Referring%20again%20to%20my%20Budget%20Cost%20col%20in%20my%20Resource%20Usage%20table%20I%20want%20to%20sum%20that%20column.%20I%20am%20aware%20that%20you%20can%20sum%20the%20summary%20by%20selecting%20an%20option%20if%20there%20is%20a%20group%20filter%20set%20where%20u%20will%20get%20a%20summary.%20In%20my%20resource%20usage%20table%20the%20display%20has%20no%20summary%20just%20pure%20cost%20items%20in%20every%20columns%20and%20the%20first%20col%20are%20the%20different%20resources%20names%20as%20defined%20in%20my%20Resource%20Sheet.%3CBR%20%2F%3E%3CBR%20%2F%3EHope%20my%20reply%20gives%20more%20clarity%20on%20my%20questions.%3CBR%20%2F%3ELook%20forward%20to%20your%20reply.%3CBR%20%2F%3ERgds%3CBR%20%2F%3EKR%3C%2FLINGO-BODY%3E
Occasional Contributor

Hi

 

Have 2 questions with regard to Ms Project custom field usage.

 

1. I have a very simple question but I don't seem to be able to get it right.

I am trying display a blank field on a new custom column of type number using custom field.  Below is the formula I am using:

 

IIf(([Budget Cost]<>""),Round(([Budget Cost]/186000)*100),"")

 

I am checking the Budget Cost col and if is not empty then do the maths shown about basically finding some percentage value and rounding the final number.

 

If Budget Cost is empty/blank then I just want to leave it blank as well do nothing with it.  So for the false part I simply said "" it gave an error showing #ERROR I guess why this so - because the new custom field is of a type number and I am trying to store an empty string.

 

So I even replace the false part with [Budget Cost] meaning if it is empty just copy the empty field into my new custom col. Still it gave me #ERROR

 

I tried replacing with NULL also did not work. For now I have replace the false part with number 0 and it work fine but I have 0 displayed for those Budget Cost cells with blank field. This is very ugly and I dont like this. 

 

I just want to display an empty field/ blank...How do I that,  

 

2. Also one side question how do a get sum of a row of numbers...at the moment as u can see in my formula I am manually inserting the sum of the Budget Cost column as  $186,000 to  get my percentages. Is there a function, built in field etc that I can use?

 

Any help my appreciated.

 

Rgds

KR

9 Replies

Well, you're right in that the error occurs because you are trying to write a string ("") into a custom Number field. However, even if you change the formula to write a zero, the end result will ALWAYS be zero because the Budget Cost field is only applicable to the Project Summary task so no task field will ever have a budget cost. You cannot show a "blank" in a Number field, but you can use a Text field to show nothing.

On your second question, you can get the sum of a row of numbers by creating a custom field that is the sum of each element in the row (e.g, Number1 + Number2 + etc.). However, I think what you perhaps are asking is how to get the sum of a column of numbers (e.g. sum up the Number1 field). For the latter, you simply check the option "Calculation for task and group summary rows" and select "sum"

Hi John
Thank you for your prompt reply. Appreciate your response.

1. I agree Budget Cost can only be applied to the Project summary. But what I have done is that I created a Table based on Resource Usage and in that table I have a Budget Cost col which displays all the Budget cost for each resource item. However some cells in this column can be blank. Then I created a custom field to calculate the percentages based on my earlier formula I showed. That's where my question is about for those blank cells I want to ignore calculating the percentage.

2. Yes I am asking for the sum of numbers in a column. Referring again to my Budget Cost col in my Resource Usage table I want to sum that column. I am aware that you can sum the summary by selecting an option if there is a group filter set where u will get a summary. In my resource usage table the display has no summary just pure cost items in every columns and the first col are the different resources names as defined in my Resource Sheet.

Hope my reply gives more clarity on my questions.
Look forward to your reply.
Rgds
KR
Okay so are you saying you created a custom field in the Resource Usage view that you are calling "budget cost" but it is not Project's Budget Cost field? If so, then that would have been good to know at the onset.

What is this "table" you created? Is it a lookup table? What is the field name (i.e. Project name not your custom name)?

A screen shot would be really helpful. Remember, I'm not inside your head so I can't see what you are doing or what you are thinking, you have to explain in in terms as you would to a third party. Maybe you can sense my frustration.

When you customize a field in a Usage view (Task or Resource), that formula applies ONLY to the resource or task data, NOT to the assignment data. You cannot create a custom field formula for assignment rows. However, you can use VBA to create a macro that will calculate assignment row data and can also roll it up to the resource or task rows.

@John-project 

 

dear John

 

My humble apologies for  getting you frustrated over this issue that I am trying to explain. I will provide the screenshot as well hopefully this will help. I have create a View of my report and I will explain what I want to do.

 

Report-Demo.JPG

 

 

I have a col Budget Cost which is NOT a custom field it gives all the Budget allocation as defined in the Resource Sheet.  %Budget is the custom field which is now of type Text (as suggested in your earlier reply so that I can display blank/empty cell for those cells that I do not have any budget values during my percentage calculation. This is working the way I want now.

 

In order to calculate % tages I need to know the total of the Budget Cost column which is $34,500 + $38,000 + $70,400 + $28,100 + $15,000 = $186,000. I am now manually inserting $186,000 in the formula in my custom field to get the %Budget figures.

 

My question is how can I get this col sum of Budget Cost to avoid hard-coding $186,000 in the custom field.

 

Lastly, your last statement  "You cannot create a custom field formula for assignment rows. However, you can use VBA to create a macro that will calculate assignment row data and can also roll it up to the resource or task rows." - is they any youtube video that I can watch to understand what you meant here or any article that I can read or any example that I look at and understand this.

 

Once again appreciate you taking  a lot your time in looking at this issue I have.

Rgds

KR

 

 

@KR 

IT would have been easier if you had presented this data at the beginning.

 

I think I figured out a way to get what you want but I'm having some issues getting it to work. It will take me a couple of days.

John

best response confirmed by KR (Occasional Contributor)
Solution
Okay I've got something that appears to work.
1. In the Resource Usage or Resource Sheet customize the Resource Text1 field with this formula and check the option to "use formula" for task and group summary rows::
IIf([Budget Cost]<>"",round([Number1],1) & "%","")

2. This macro will populate the Resource Number1 field with the desired percentage data
Sub CustomBud()
Dim Den As Single
Dim CFF As String
Den = Round(ActiveProject.ProjectSummaryTask.BudgetCost)
CFF = "iif([budget cost]<>"""",[budget cost]/" & Den & "*100,0)"
CustomFieldSetFormula FieldID:=pjCustomResourceNumber1, Formula:=CFF
CustomFieldPropertiesEx FieldID:=pjCustomResourceNumber1, Attribute:=pjFieldAttributeFormula, _
summarycalc:=pjCalcFormula, GraphicalIndicators:=False, AutomaticallyRolldownToAssn:=False
ViewApply Name:="resource sheet"
ViewApply Name:="Resource Usage"
End Sub

This was challenging.
John
Hi John

Thanks a lot for the solution. This awesome! I guess if things don't work the normal way we can always do some programming to solve it. I am not very familiar with VB and I got your code to work in my project file. I need to understand some of the variables that you used which are MS Project dependent. Is there a site I can go to see all possible MS Project's variables that I can use to manipulate data?

One last thing I need to know is that if I want to display all my fixed cost items that are assigned to some Tasks ( fixed cost column) on the same report I attached previously (which is more of a resource level cost information) is that possible? Is there a work around?

Or is it a rule that we cannot combine Resource level data with Task level data period!
Once again thanks a lot for your help. Much appreciated.
Best Rgds
KR
What you really need to understand is the Project Object model. You might look at the following:
https://docs.microsoft.com/en-us/office/client-developer/project/project-home?redirectedfrom=MSDN

To answer your other questions, with VBA you can combine any Project (e.g. project, task, resource, assignment) data to form a report. Depending on thr format sometimes it is possible to create the report in Project, as I did for you in this scenario, but normally I find it much more flexible to export Project data to Excel to create virtually any custom formatted report.
John
Hi John

Thanks again. Until I hit another problem I will post another discussion. Until then take care.
Cheers!
Stay Safe