This post is old and probably irrelevant today.

07 April 2019

How to display images in Google Data Studio's tables

In Data Studio, we can use table charts to display our data in a grid of rows and columns. But these tables don't have to only contain text and numbers.

Here is how to enrich them with links, images, and dynamic images.

In this example, we use a list of cetacean species from this Wikipedia page. Our data set is a Google Sheet, but it would work with any other source.


A- Links

Let's start by making the name in our first column clickable. To do so, we need to create a new field which we will use to combine information from 2 existing fields. The new field is called a calculated field.

To create it, we go to "Resource > Manage added data sources" (1).

We click "Edit" on our data source (2).

We click "Add a field" (3).

We give the field a name (4), and use the HYPERLINK function to combine:

1- The url to open (5)
In our example, it's the "Url" field, containing values like:

  • https://en.wikipedia.org/wiki/Antarctic_minke_whale
  • https://en.wikipedia.org/wiki/Blue_whale
  • https://en.wikipedia.org/wiki/Bryde's_whale
  • https://en.wikipedia.org/wiki/Common_minke_whale
  • ...

2- The label to use for the link (6)
In our example, it's the "Common name" field, containing values like:

  • Antarctic minke whale
  • Blue whale
  • Bryde's whale
  • Common minke whale
  • ...

We save (7) and click "All fields" (8) to go back to the list.

We can see the new field listed on our data source (9). The "fx" label allows us to recognize calculated fields. We click "Done" (10) to go back to our report.

In our table, we replace the original field (11) with the new calculated field (12).

The names in out list of whales are now links. Clicking them opens their respective Wikipedia pages in a new tab.

B- Images

To display an image from its url, we create a new calculated field like we did in step A.

We use the IMAGE function. It takes 2 parameters:

1- The url of the image (1)
In our example, it's the "Picture url" field, containing values like:

  • https://upload.wikimedia.org/[...]r_-_NOAA_Photo_Library.jpg
  • https://upload.wikimedia.org/[...]nky_whales_%28js%29_13.jpg
  • https://upload.wikimedia.org/[...]hiewebb-swfsc-star2006.jpg
  • https://upload.wikimedia.org/[...]Minke_Whale_%28NOAA%29.jpg
  • ...

2- The text to use as an alternative (2)
In our example, it's the "Common name" field, containing values like:

  • Antarctic minke whale
  • Blue whale
  • Bryde's whale
  • Common minke whale
  • ...

The alternative text provides the image's alt attribute, which can be used by screen readers to assist vision-impaired users. It's also displayed if the image fails to load.

If we want to compose an alternative text with multiple fields or text strings, we can use the CONCAT function (3):

After saving, the type of this field clearly indicates "Image" (4) in our data source:

In our report, the same icon allows us to identify all image fields (5):

What if we need a link on an image? We simply encapsulate it in a HYPERLINK (6):

Our field's type then becomes "Image Link" (7):

C- Dynamic images

It's a common situation to need to build image urls from an identifier, like a product ID, a video ID, a "slug" associated to a blog post, or any type of code.

In our example, we have the field "IUCN category code", a conservation status code with values like:

  • LC
  • NT
  • VU
  • EN
  • ...

We can use the CONCAT function to compose an image url from this code:

Here is how this field looks in our report:

A more complete example with an alternative text and a link to the Wikipedia page:

Our end result: