I am new to ArcGIS Pro and have just a "Basic" license. I have no Python coding experience.

I am trying to make a ModelBuilder tool that will Union multiple feature classes (as little as two but maybe up to 20). Since I only have the Basic license, I can only Union two feature classes at a time.

When I perform this manually I set up a bracket like this:

enter image description here

I union ShapeW to ShapeX to form Union 1. I then Union ShapeY to ShapeZ to form Union 2. I then Union 1 and 2 to form my final Union 3. With more shapes, my bracket just expands to more levels.

For my ModelBuilder I am using the following flow:

  • Iterate Feature Classes
  • If %n% <> 0 then go to Branch 1
  • If %n% = 0 then go to Branch 2
  • Both branches are similar in that they remove fields, delete rows etc. the difference is that Branch 2, exports the current Feature Class as Union0.
  • I would like to have Branch 1 "Union" the current feature class (%n%) and the previous feature (%n%-1). So if %n% =1 it would Union the current feature class (ShapeX) and the previous %n%-1 (Union0).

The inline variable %n% keeps a count of the iteration. I would like use %n%-1 as an inline substitute variable. Is there a way to do this?

enter image description here

  • 1
    You could use the model only tool Calculate value to return the value %n% - 1.
    – Hornbydd
    Oct 31, 2022 at 14:45
  • Thanks. Does Calculate Value change with each iteration? How do I bring that value back into the model for use as an inline variable?
    – Bob
    Oct 31, 2022 at 20:24

1 Answer 1


You can use Calculate Value with the expression "Union"+str(%n%-1) to identify the name of the feature class created in a previous iteration. This is just the concatenation of the known part of the feature class name (Union in your example) with the iteration count %n% - 1 wrapped in the Python str() function which converts the count integer to a string value.

  • Thanks!! That was it.
    – Bob
    Nov 1, 2022 at 17:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.