How to Bulk Convert Looks to Lookless Dashboard Tiles (Using the Looker API)

Looker will not be updating this content, nor guarantees that everything is up-to-date. 

The Problem


I have a dashboard with Look-based tiles, or a tile that is linked to a Look, as explained in the Creating User-Defined Dashboards documentation. I would like to convert all the tiles on the dashboard to Lookless tiles in order to remove clutter from my folder (called "Spaces" before Looker 6.20), since Look-linked tiles require that the associated Looks exist in the same folder as the dashboard.

Each dashboard tile has an option to Convert Look to Tile, as detailed in the Editing User-Defined Dashboards documentation. This is a great workflow for converting tiles on dashboards with few tiles, or in cases where we may not want to convert all tiles on a dashboard, as it involves editing each tile individually. However, what if we want to convert all tiles on a dashboard in bulk?

The Solution


Using the Looker API 4.0, it is possible to do this with a script in the programming language of your choice. You can use update_dashboard_element parameter to change the Look ID to null, which turns a Look-based tile into a Lookless tile.

Here is a pseudo-code implementation example. First, you'll need to authenticate into your API and obtain the session, which is outlined in great detail in Looker's API Authentication documentation. This pseudo-code example assumes that you want to convert all of the tiles on the dashboard to Lookless tiles.

# After getting the dashboard_id of the Dashboard you want to edit:
SET dashboard = GET_DASHBOARD(dashboard_id);

# GET_DASHBOARD gives us an array of dashboard elements

SET dashboard_elements = dashboard[dashboard_elements];

FOR(element in dashboard_elements)
{
# A dashboard element object contains an id, query_id, and look_id
SET element_id = element[id];
SET query_id = element[query_id];
SET look_id = element[look_id];
IF(look_id is not null AND query_id is null)
{
# If the look ID is not null but the query ID is, then this is a Look-based tile.
# We now need to get the query ID from the Look so we can put it in the dashboard tile.
SET query_id = GET_LOOK(look_id)[query_id];
UPDATE_DASHBOARD_ELEMENT(element_id, { "look_id":nil; "query_id":query_id;}
}
# Else do nothing - this is already a Lookless tile.
# Note that we don't check for merge query ID. This is because Merged Results cannot be saved as Looks, so do not need to be converted.
}

This script visits the specified dashboard, and checks each tile/Look to see if the tile is indeed a Look-based tile, and if so converts it into a Lookless tile.

Note: This does not actually delete the associated Looks from the folder where the dashboard lives. You can delete these in bulk from the folders page afterward if you like.

Version history
Last update:
‎06-22-2022 10:10 AM
Updated by: