If you are one of the increasing number of Power BI users that have discovered that the Visio Visual gives you the great ability to include Visio diagrams in your dashboard, then you may have come across the following error, ‘We can’t open your file in Visio because it exceeds the shape count limit’ in Power BI’, when you try to embed a Visio document. This can be frustrating, but here is a deeper explanation of what is happening … and how you can usually overcome it.
The Visio Visual in Power BI currently has a 1k shape limit, and it will reject any page that exceeds this limit. So what can you do to overcome this issue? Well, Microsoft has provided the ability to use layers with a # prefix in their name to tell the Visio Visual to only count shapes assigned to those layers. Useful, but using this feature is not always as straight forward as it seems.
Firstly, you may open up the Layer Properties dialog in Visio, and it shows you a count of each shape on each layer, but you might think that this count is crazy because you only have a handful of shapes. In this example, I know that I will be linking the Person shapes to data in Power BI, and I only have 24 of them (in a past life I used to data-linking 600 person shapes per floor). This count includes all of the sub-shapes within each shape, and don’t forget that Visio shapes can belong to none, one or more layers! Therefore, some shapes can be counted more than once, and some are not shown in this dialog at all because they don’t have a layer assignment!
I have enhanced my LayerManager add-in (new release available now) to list the count of shapes on each layer, and the count of the shapes on the top of the group shapes. It also gives you the count of the shapes and sub-shapes without any layer assignment!
So, if I look for deeply into one of the Person shapes using the Drawing Explorer, I can see that it has many sub-shapes, but some of them are on the Data Graphic layer. In fact, the Visio Visual in Power BI will supress the Data Graphic shapes automatically.
I find the Drawing Explorer view of the shape a little complex to see what is actually there, so the soon-to-be-released enhanced LayerManager add-in provides an alternative view by providing a tree view of each shape and sub-shape, displayong its master name in square brackets, and a list of the layers that each shape belongs to.
So, if I was to rename the Person layer as #Person then the Visio Visual will only include the shapes on each layer whose name begins with a # character. Thus my 24 Person shapes, which each consist of 3 shapes on the Person layer, would make a total of 72 shapes in the whole page. This is far less than the 1k shape limit for the Visio Visual, and so I will be able to use the Visio page, even though it has nearly 2k shapes on it.
However, if I had 600 Person shapes, then there would be 1,800 shapes, which is still larger than the 1k limit, and it would again fail.
Therefore, the better solution is to create a #Person layer, and only move the top shape in the Person master to this layer, leaving the 2 non-Data Graphic sub-shapes on the Person layer. Therefore, there will only be 600 Person shapes counted by the Visio Visual!
The only problem is that this last edit is impossible to do in the Visio user-interface, and needs to be done with some custom code. Hence another reason why I had to enhance my forth-coming LayerManager add-in!
Another useful technique before embedding Visio pages into Power BI, is to greyscale the whole page by adding a suitable colour to each layer, thus over-riding existing colours and providing a much clearer background for any text and colors added in Power BI.
So, now, the Color by Value feature of the Visio Visual in Power BI can be used to clearly indicate shapes with colour.
Whilst I was working on this code, I came across a solution given in the Power BI community – Visio Visual – Too Many Shapes . This looks like too much effort for most users to me…. Just ensuring that the top shape in the group is on a # named layer is much more preferable.