Microsoft Visio has a useful Structured Diagramming concept that consists of Containers, Callouts and Connectors. The first of these features make it possible for shapes to know what they are contained within, as a better option to grouping shapes together. Grouping can hide or break the grouped shapes smartness, so Visio provides two ways of allowing shapes to be members of one or more containers. There are a few built-in Container shapes that can be added with the Insert / Diagram Parts / Container gallery, but shape developers can also create their own. Member shapes can be positioned anywhere within the container. There is a second type of container, List, that provides the ability to have ordered member items. There is no ribbon command to add these, but there are a number of these special shapes provided in the OOTB Visio stencils. For example, dragging and dropping a List box shape from the Software and Database / Software / Controls stencil will automatically add three List box item shapes to it.

There is a dedicated ribbon tab, Container Format, that appears when you select a container shape, which provides some extra commands, but I want to demonstrate how a member shape can reference data in its container shape in the ShapeSheet. I edited the Belt and List box masters in the Document Stencil above by adding a Title Shape Data row. Of course, I also ticked the Master Properties / Behavior / Match master by name on drop option to prevent Visio creating duplicate masters. I also ticked this for List box item master because I want to edit that too.
First, I simply added a Shape Data row to each master, but made them read-only so that they displayed the text in the heading shape of each.
The Belt master’s heading shape is Sheet.8, so the Prop.Title.Value cell formula is:
=GUARD(SHAPETEXT(Sheet.8!TheText))
The List box master’s heading shape is Sheet.6, so the Prop.Title.Value cell formula is:
=GUARD(SHAPETEXT(Sheet.6!TheText))
Next, I edited the text of the List box item master by using Insert / Field:

The following formula will either display the position of the item within its List container, or it will display that it is #0 of no list.
="#"&LISTORDER()&" of "&IFERROR(LISTSHEETREF()!Prop.Title,"no list")
The LISTORDER() function will return the position in the list, and LISTSHEETREF() function gets a reference to it. The ISERROR(…) function provides the fallback value if the specified cell does not exist in the referenced list container, or if there is no list container at all. The list container could also make use of the LISTMEMBERCOUNT() function if you wanted to display that.
The rectangle shape text was also edited to display the Title Shape Data of its container.

This is the simplest form of the CONTAINERSHEETREF(…) function, because it simply references the first container it is within:
"I am in "&CONTAINERSHEETREF(1)!Prop.TITLE
Of course, the CONTAINERSHEETREF(…) expression could also be enclosed within an IFERROR(…) function, to handle the case where there is no container. In addition, the CONTAINERSHEETREF(…) function has an optional second argument to filter the collection by a named shape category. There is also a CONTAINERCOUNT() function to get the total number of containers that a shape is within, and a CONTAINERMEMBERCONT() function for a container to get the number of members that it has.

Note that I had to re-drop a List box item shapes to use the new text formulas automatically.
These functions are also used extensively in Cross-Functional Flowchart diagrams, where multiple container shapes (swim-lanes) are found within a list shape. All of this functionality works in Visio for Web, so there is no excuse on making smart shapes for everyone!
Pushing Data Visualizer in Visio beyond its limits
My last post was about some of the lessons learnt when trying to push Data Visualizer to its limits, but this one has some ways of overcoming these limitations. The main lesson learnt is that DV binds the shapes within the DV container shape, CFF Data Visualizer, and controls some of the ShapeSheet cells that…
Pushing Data Visualizer in Visio to the limits!
Regular readers of my blog will know that I like to use the Data Visualizer (DV) in Visio Plan 2, but I recently tried to help a user who really decided to push it to the limits. In this scenario, there were multiple connections, but with different labels, being created between the same flowchart shapes,…
Setting Theme defaults in Visio
I was recently asked how to change the default font size and line weight in Visio, and then saw then many others are asking the same sort of question. I found one reasonable answer suggesting that you should create a new document from your required template, then edit the Styles to suit, and then save…
Taking Visio Actions Rows to the limit
I recently (re-)discovered that there is a limit to the number of Actions section rows that will be evaluated for display on the right mouse menu of a Visio shape. I have not hit a limit (yet) for the number of rows that can be added to the Actions section … so why is there…
A Multi-Time Zone Clock for Visio
I wrote a post about making a clock face in Visio fifteen years ago, but a reader recently asked about displaying multiple time zones. Well, I have previously written about time zones in Visio, so I accepted the challenge to improve upon my earlier work. (more…)
Update any Visio ShapeSheet cell with External Data
When Microsoft introduced a new way of linking external data to Visio shapes in 2007, I initially bemoaned the inability to update anything but Shape Data row values, unlike the old database add-on that I had been using for 10 years. The new method, though, has many advantages over the old way, not least that…
Hi David,
please, if you can, tell me what book or tutorial I should buy to learn how to make a business process simulation in Microsoft Visio. After I map the processes and highlight the cost and time elements in Shape Data, I need Visio to automatically calculate the costs, times and other characteristics of a process from Start to End.
Thanks
Calculation from Start to End depends upon the route taken through the process. You can build in many types of calculation into Shape Data, but are you trying to calculate all of the different options?