Skip to main content

Hi! I’m a Sr SE at Lucid and wanted to share a way to calculate the step number on your shapes - in a way that handles branching.

 

The way that I do this can be seen in the following video, and I’ll include screenshots below.

 

VIDEO: https://play.goconsensus.com/aa349b532

 

The formula that I put at the page level - and “Apply to all shapes” - is the following:

=if(count(upstream) = 0, 1, if(count(UPSTREAM) = 1, upstream."Step Number" + 1, filter(upstream, x => doesnotcontain(upstreamdeep(x).$id, this.$id))."Step Number" + 1))

Note: I choose to call my Property “Step Number” and that formula is the value that I give to it. If you use a different name, update your formula accordingly.

 

Conditional Formatting Rule:

 

 

RESULT:

 

Hello,

I greatly appreciate this formula for most of my process flows. However, I found it stopped working when two branches combined, both branches leading to the same shape. The next shape in sequence runs into an error calculating the formula. Is there a way to update the formula to account for this?


Hi Dillon,

The error you’re encountering is that, with multiple branches leading to a single shape, the formula is trying to add 1 to an array, which it can’t do. There are a couple ways to fix this by taking either the max or the min of the array. I changed the formula to take the max, shown below with changes in blue, and got this image as a result.

=if(count(upstream) = 0, 1, if(count(UPSTREAM) = 1, upstream."Step Number" + 1, max(filter(upstream, x => doesnotcontain(upstreamdeep(x).$id, this.$id))."Step Number") + 1))

 


Reply