Data driven bookmarks

This week I visited a customer who for whom we’re building a Power BI report to replace a bespoke portal created in JavaScript. The new report has multiple pages of options allowing the users to drill into more detail about the data. We’re going to use icons powered by Power BI bookmarks to provide this navigation.

However, the customer was very clear – they don’t want the icons to appear when there isn’t the detail available to view. Currently in Power BI there isn’t a native way to make an icon be visible or hidden based on data.

Whilst it’s not a perfect work around, the technique described here describes how to make a bookmark show or not show depending on the data. In the example shown in the video below, there is information about customers – sales and orders. All of the customers have sales data, but not all have order information. There is a Power BI button that navigates to an order detail page using bookmarks. We don’t want the button to show if there is no order information.

We achieve this by using an image for the icon and put a blank button on top. The URL for the icon is a DAX measure, which checks to see if there is order information present. If there is it returns the URL of the image, and if not, returns an empty string. It’s not perfect, as the button still works, even if the icon is not showing, but hopefully it will deter most people from clicking.

We couldn’t put a blank image over a Power BI button to hide or show it, as the z-index would prevent the button being triggered ever – the image visual would be on top of the button.

I’m hoping that once expression based formatting is available, it will be possible to achieve this without needing a workaround, but if not it might be possible to improve the workaround.

Here are the steps to implement the workaround:

  1. Create bookmark on the detail page
  2. Create a measure using DAX to return the image URL:

    for this example –

    Icon = IF (COUNTROWS(Orders) > 0, "https://<imageurl>", "")
  3. On the summary page, add the image. I used the Image by Cloudscope custom visual. Use the new Icon measure we created in the Image URL field.
  4. Add a button and place it on top of the image. In the formatting options, set the Action Type to Bookmark and select the bookmark you created in step 1.
    Turn off Border to hide the box surrounding the button.

https://app.powerbi.com/view?r=eyJrIjoiM2E4YTJiNDUtYjdlYy00NGE3LWEyYjktY2E3YTFmYzMwYTk2IiwidCI6IjBjNzk5ZDM4LTQ3NjQtNDJiYy1iNGZmLTIzYmViYTljN2ZlMiIsImMiOjh9

Also I feel I need to credit David Elderveld, as I’ve just discovered his blog post here on a very similar technique for using data driven images.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s