Use of flags to autofill gantt view RRS feed

  • Question

  • Hi Everyone,

    Ive been using flags to create custom bar styles and colour in my gantt chart automatically.

    You are probably already ahead of me by now but what do I do when I hit the 20 flag limit?

    Is there a way around this?

    I am happy to use the same colours again as there will be a natural break but hpow do I write the formula for this

    eg I am using "IIf([Name]="A04",Yes,No)" at the moment

    How do I say If X OR Y OR Z then Yes/No?

    Thanks for any help you can offer


    Thursday, April 3, 2014 8:11 AM

All replies

  • Hi Alex,

    we have only 20 flag fields in Project, that's right.

    But you can combine more parameters in one formula. The easiest way ist to use the Switch function.

    For your example the formula would look like this: Switch([Name]="X","Yes/No",[Name]="Y","Yes/No",[Name]="Z","Yes/No")

    The generic Switch Function Looks like this: Switch( Expr1, Value1, Expr2, Value2, ... )

    Hope, this helps.


    Bernhard Fischer

    Bernhard Fischer [MVP] |

    Thursday, April 3, 2014 9:22 AM
  • Thanks Bernhard,

    Now you have said it it seems obvious! I guess I could also use a nested IIF statement similar to that in Excel?

    Your suggestion works perfectly though!

    Thanks so much


    Thursday, April 3, 2014 10:19 AM
  • Hi Alex,

    Note that since flag is a boolean, it can only return 2 values (yes or no). If you want to use nested iif statement, you then have to use a text field.

    I deducted from your question that you wanted a flag field in order to customize bars in the Gantt chart, which can only be done with flag fields.

    If you don't need to format the bars in the Gantt then you can use a text field with a nested IFF statement.

    Hope this helps.

    Guillaume Rouyre - MBA, MCP, MCTS

    Thursday, April 3, 2014 12:39 PM
  • Hi Guillaume,

    what you've written, is not quite right!

    Yes, a flag field is a boolean and returns you yes or no.

    But in the context that Alex has described the use of a nested IIF Function in the formula property of an user-defined Attribute field is definitely possible, because he compares the different task names! And in dependancy of a special task name he get the value "yes" or "no". That's it was he need for formatting the Gantt-Chart.

    Best Regards

    Bernhard Fischer

    Bernhard Fischer [MVP] |

    Thursday, April 3, 2014 1:00 PM
  • I don't know if this helps but here goes. Nested IIFs cannot be nested more than 7 deep, and they are ghastly to write, check and test.

    But I think you could define a big number of styles like this:

    A flag field is like a 1 bit binary number which can express two values, 0 or 1.
    If you combine 2 flag fields you have a 2 bit binary number which can express 4 unique values.
    .. and so on, and if you have 20 flag fields you can have 2^20 values which is a lot, and each distinct, unique combination can be used to trigger a different colour for a bar in bar styles. Here is the first 8 numbers/colours done with 3 flags.

    The style for the last one here would be defined as flag1,flag2,flag3


    Tuesday, April 8, 2014 6:25 AM
  • This is great idea and will help if the number of flags checked is more. I would want to add more point on how this can be done if we have three flags.

    a. Insert a custom text field, say Text1

    b. Right the custom text field, click Custom Fields

    c. Click Formula in Custom Attributes and write a formula


    d. Format the bar style based on the value in Text1

    Sai PMP, PMI-SP, MCTS Project, MVP Project

    Tuesday, April 8, 2014 7:18 AM