Skip to main content
Leah W
Lucid support team
August 3, 2023

Auto-Number your Flowchart in Lucidchart

  • August 3, 2023
  • 29 replies
  • 4733 views

Looking for a way to auto-number the steps in your flowchart? Check out this post on how you can utilize conditional formatting and formulas to accomplish this!  

Please use the steps below to accomplish this on your diagram.

1. Add shape data "Start" to a start node with the value 0. This allows shapes connected to it to know it's part of the flow chart (as opposed to the note).WDRHIlKDibqK-4j8DRbs5A.gif

2. Add data "Distance" to all of the shapes with the formula =count(upstreamdeep) + upstreamdeep.Start. This will be defined with the distance from start or error (if the shape is not in the flow chart).

3. Add page data "Numbering" with the formula

=groupby(map(sort(filter(children, x => and(not(iserror(x.Distance)), itemtype(x) = 'Block')), 'asc', x => x.Distance + 0), x => object('id', label(x), 'index', x.index)), x => x.id, x => x.index)

. This formula sorts all blocks in the flow chart by distance and then groups them into an object where the key is the shape label (ID) and the value is the index returning in a mapping from block to unique numbering.   

4. Lastly add a conditional formatting rule to add a badge when NOT(ISERROR(@Distance)) and itemtype = 'Block' (to prevent them from showing on lines) with the formula =GET(Page."Numbering", label) for the badge label. See screenshot for what the  conditional formatting rule should look like (no else condition needed for this).

A9lOMHf_v1HFqYD0EiH-iw.jpg

These steps will allow you to easily add and update step numbers to process flows while eliminating any duplicate numbers! 

Useful Links:

Conditional Formatting in Lucidchart 

Formulas help center article

Pinned Reply By geoffmaddox

It looks like there was an error in the original formatting of the formula in Step 3 that stripped out the commas. Here’s the corrected formula with the commas added in (the original post has been updated):


=groupby(map(sort(filter(children, x => and(not(iserror(x.Distance)), itemtype(x) = 'Block')), 'asc', x => x.Distance + 0), x => object('id', label(x), 'index', x.index)), x => x.id, x => x.index)

Comments

April 19, 2024

There seems to be a bug, where if I connect multiple lines to end at a single shape, something breaks and the number disappears. 

My current workaround is for all arrows (except the first one) which terminate at a single shape is to draw them to finish just short of touching the shape. Again this seems to work, but its not great because if you look closely there’s a small gap. Not a big deal, but curious if anyone knows a better fix?

geoffmaddox
Lucidite
April 19, 2024

There seems to be a bug, where if I connect multiple lines to end at a single shape, something breaks and the number disappears. 

My current workaround is for all arrows (except the first one) which terminate at a single shape is to draw them to finish just short of touching the shape. Again this seems to work, but its not great because if you look closely there’s a small gap. Not a big deal, but curious if anyone knows a better fix?

With multiple lines connecting into a shape, the value for upstreamdeep.Start returns multiple values, which causes the formula =count(upstreamdeep) + upstreamdeep.Start to fail.

A workaround would be to choose the first upstreamdeep.Start value (from the original post, there should only be a single shape with a Start value). To do this, change the Distance formula to:

=count(upstreamdeep) + asarray(upstreamdeep.Start)[1]

 

May 10, 2024

can it also be numbered by letters also like abc?

It is actually possible to number using letters instead of numbers, but the formula becomes slightly more complex.

 

In order to number by letter, we need to be able to convert the index (1, 2, 3, ...) into a letter. There are two formula functions we can use to do that, CODE and CHAR. Generically, the formula looks like this for a given number (with 1 => A, 2 => B, etc.):

char(code('A') + number - 1)


This only works with letters A through Z (numbers 1 through 26), however, so the formula gets slightly more complex to handle numbers above 26. In order to do that, we need to handle each digit separately. For values up to 702, using the following formula in place of Step 3 will work to number using letters (where they are lettered with A to Z, then AA to ZZ):
=groupby(map(sort(filter(children, x => and(not(iserror(x.Distance)), itemtype(x) = 'Block')), 'asc', x => x.Distance + 0), x => object('id', label(x), 'index', if(x.index > 26, char(code('A') + floor((x.index - 1) / 26) - 1) & char(code('A') + mod(x.index - 1, 26)), char(code('A') + x.index - 1)))), x => x.id, x => x.index)

 

This results in this numbering, which is valid for up to 702 shapes (ZZ):

 

Beyond 702, the formula becomes much more complex.

Is there a way to use decimals? (example 1.1, 1.2, 1.3?)

Micah
Lucid community team
May 10, 2024

Hi @Hbusey, thanks for continuing this thread! To clarify, would all steps in your flowchart begin with a “1”, or would your process at some point shift to 2’s (2.1, 2.2, 2.3...), 3’s (3.1, 3.2, 3.3...) and so on? 

May 10, 2024

Hi @Hbusey, thanks for continuing this thread! To clarify, would all steps in your flowchart begin with a “1”, or would your process at some point shift to 2’s (2.1, 2.2, 2.3...), 3’s (3.1, 3.2, 3.3...) and so on? 

If it would be possible to have the option to shift to 2’s and 3’s that would be amazing! The use case is that we have process maps where the high level process is 3.0 and then steps within that process are 3.1, 3.2, 3.3, etc. Is that possible? 

Micah
Lucid community team
May 10, 2024

I see, thank you! The difficult aspect here is converting the index of the shape into the desired sub-step label, in the same way in the example above we had to convert the index of the shape into a letter, as well as telling Lucidchart at which point steps shift to 2’s and 3’s. I’ll tag in @geoffmaddox and @khaleesioflucidchart as formula pros for their insight here. 

July 24, 2024

This is a super-helpful resource, and will replace time-consuming manual numbering! I’m wondering if it’s possible/how to eliminate specific shape types from the numbering process, so that for example, only Process shapes are numbered, and everything else (flow switches, terminators, etc.) are not. 
Do you have any suggestions on how to edit the formulas here to do so?

September 25, 2024

Awesome workaround! thanks for the post! 

Q: How do you export those custom numbers to the googlesheet? and how do you adjust the formatting? Such as font of the font, color, border etc from the text badge?

Thanks! 

Micah
Lucid community team
September 25, 2024

Hi @z.reiser, apologies for the delayed response here! The original formula builds a mapping of the shape to it's index (as defined by the ordering), so the mapping could be updated to first filter to a particular shape type.

Could you please try something like the following, where ShapeTypeHere is the specific type of block to filter by?

=groupby(map(sort(filter(children, x => and(not(iserror(x.Distance)), itemtype(x) = 'Block', shapetype(x) = 'ShapeTypeHere')), 'asc', x => x.Distance + 0), x => object('id', label(x), 'index', x.index)), x => x.id, x => x.index) 

Micah
Lucid community team
September 25, 2024

@ChiliC Thanks for your questions!

 

Regarding export - to clarify, is your ultimate goal to have a spreadsheet with a column containing the step and another column containing the step number?

 

Regarding changing the formatting - currently, Lucidchart supports editing the following fields for a badge applied via conditional formatting: style, color, custom hover text, and position. 

These are all available within the conditional formatting menu when creating the “then” part of the rule. If you’d like to see additional attributes, like font and border options, available here, we would love to hear more! We’re very interested in your feedback and committed to continually improving our products. Please first search the Product Feedback section of this community (with the filter Topic Type = Idea) to see if it’s already been submitted. If so, please add any additional details you’d like and upvote the request - this consolidation helps to refine feedback and properly capture the popularity of the request.

If no one has submitted this idea yet, please create one of your own and be sure to include details about your use case or what you’d like to see in this experience. This will also allow other users with similar requests to discover and upvote it, then add details of their own.

Finally, for more information on how Lucid manages feedback via this community, take a look at this post: