Chris Hopkins' Blog - #makinitdostuff

The place where I post information about the products I manage; SharePoint, Yammer, Project and Visio and maybe from some that I don't!

Shapes that calculate based on their container

Shapes that calculate based on their container

  • Comments 1

The new containers feature in Visio 2010 is fantastic.  If you have not heard of this feature then check out the product team blog article about containers, here http://blogs.msdn.com/b/visio/archive/2009/08/25/organizing-diagrams-with-containers.aspx

What I want to point out to all you shape developers how you can use some simple new ShapeSheet formulas to allow shapes to base calculations on the container they are associated with.

Take for example…

image

As you can see, I have setup a container that has a Base Value property containing the value 10.  I also have a standard rectangle that contains a local value.  Each rectangle also has a formula that simply multiplies the local value with the container’s base value when then are associated.

The formula is simple and can be contained within a single User cell.

IF(ISERR(CONTAINERSHEETREF(1)!Prop.BASEVALUE*Prop.Value),"?",CONTAINERSHEETREF(1)!Prop.BASEVALUE*Prop.Value)

CONTAINERSHEETREF() is key.  This new ShapeSheet function returns the reference to the container.  Notice that we also need to test that against any errors if the shape is not contained within a container.  It also handles a situation where the containing container does not have the Prop.BASEVALUE property defined

image

For your convenience I have attached a sample diagram that I used for this example.

Attachment: Container Child Calculation Sample.vsd
Leave a Comment
  • Please add 3 and 5 and type the answer here:
  • Post
  • To see an extended version of this concept, take a look at this article: http://bit.ly/m2AZW4. It involves a list embedded in a container, which is, in turn, embedded in another list. The shapes in the innermost list calculate values based on data in all of the parent objects.

Page 1 of 1 (1 items)