2023 Week 18 | Power BI: SVG Clip Path

Introduction

This week’s challenge is a little SVG fun. Recent Power BI Desktop changes have allowed even further width and height adjustments for images in matrix visuals. So we will be extending this by making a bar chart of chocolate bars.

 

Requirements

Power Query
  1. Obtain the dataset from 2023-week-11 challenge or;
  2. Obtain the dataset from https://www.kaggle.com/datasets/rtatman/chocolate-bar-ratings
  3. Model and load data
Power BI Desktop

Option 1:

  1. Obtain or draw an image of a chocolate bar
  2. With PowerPoint or your tool of choice, overlay a rectangle shape of the same size
  3. Select all shapes and save as SVG
  4. Open SVG in notepad, studio code, or browser
  5. Modify the size of images and overlaid rectangle to be the same size
  6. Ensure the overlaid rectangle is the same colour as your report background
  7. Create a DAX measure that adjusts the size of the overlaid rectangle according to a variable of your choice
  8. Ensure measure category is set to Image URL
  9. Place the measure in a matrix
  10. Switch values to rows
  11. Adjust image width and height

Alternative:

  1. To learn more on SVG clip path: https://hatfullofdata.blog/svg-in-power-bi-part-3/ and https://www.sarasoueidan.com/blog/css-svg-clipping/
  2. Obtain or draw an image of a chocolate bar
  3. Obtain the SVG path or convert a PNG to Base64 https://www.base64-image.de/
  4.  Utilise clip path to fill the bars according to a variable of your choice

Dataset

Share

After you finish your workout, share on Twitter using the hashtags #WOW2023 and #PowerBI, and tag @MMarie, @shan_gsd, @KerryKolosko. Also make sure to fill out the Submission Tracker so that we can count you as a participant this week in order to track our participation throughout the year.

Solution

Solution File available for download via Data Stories Gallery

3 thoughts on “2023 Week 18 | Power BI: SVG Clip Path”

  1. Could the link be changed to the week 18 solution? I would like to check what tricks I missed 🙂

    1. Hi Pratima! Thanks for your interest in this fun challenge! Kerry wasn’t able to make a video for this challenge – but feel free to reach out with specific questions!

Comments are closed.

Scroll to Top