Overlaying an Image to get a Proportional Fill Effect in Power BI

In a super cool trick for Power BI, Miguel Myers (@myersmiguel) did an overlay between a bar chart and a duplicated image to simulate a proportional fill, resulting in this:

base example

You can see the full report here.  While he shows how to do it in a YouTube video, it took me a while to simulate it and I thought it would be nice to write it up.

To start, you will need an image to work with.  This is my initial image:

Original Image

Now make the outside of the silhoutte the same color as the background of your report.  In my case, it’s already white so I didn’t have to do anything (in Mykhael’s report, it is black).

Next, make the shape transparent:

One Image Photo

And then duplicate it as many times as the maximum for your measure, as in:

Many Images Photo

For example, for a measure that’s a percentage, you may want to have 10 shapes so that each represents 10%.

Now to the report.  Create a bar chart and remove the X axis and the title:

Clean Chart

Bring in your image over it and immediately you will start seeing the end result:

Iniial Overlay

Adjust the heights of the bar and of the image so that the bar is fully covered:

Adjusting Height

Then left-align the image to the start of the bar

Final View

So that the bar does not stretch past the image, you will need to make sure that the image is exactly and completely filled at the max value of the measure.  This will also take care of displaying the right amount of fill for the different values of the measure.

Another key point is to set the start and end values of the axis so that they don’t change with different filter selections in your report and then wreak havok on the proportions you just coordinated.

This is the final product:

Animation

 

 

0 comments:

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>