mode helix
LIVE DISCUSSIONThe case for using prescriptive analytics to re-evaluate prioritiesRegister now

May 21, 2015 2 minute read

Adding Links To Query Results

Image of author

Benn Stancil

Chief Analyst

This post is outdated. For an easier way to add links to your query results, see this example.

Query Results with Clickable Links

We look to share our work externally whenever possible. Today we're sharing a simple but surprisingly useful trick for modifying your query results: adding links.

Suppose you've created a report that returns a column of URLs. Rather than copying and pasting the URLs into a new browser tab, it's faster to click them like regular links.

So we wrote a script that creates clickable links. Simply copy and paste the script (here's the code) into your report's HTML editor and add __link to the column name when writing your query.

Script for Adding Links

The embedded table below shows what the report looks like with the added code. (Click “Results a la Mode” to explore the report.)

That's neat and all, but the long URLs are ugly. You can also use the same code to add links to cells that aren't URLs. In the example below, the company names link to Crunchbase profiles.

To create links like these, open up the HTML editor and look at these few lines of code, starting on line 9:

Modifying Columns

For each column you'd like to make a link, add that column's name after column:. Then, define the URL. If you want to include the contents of a cell in your URL, simply add {{anycolumnname}} in the URL string. The contents of that column (which doesn't have to match the column you're making a link) will get filled in as part of the URL. You can also combine values from multiple cells as you build your URL.

Reports As Data Applications

At Mode, we use these links, combined with report parameters, to make simple data applications that let us walk through several layers of data.

The three-column report below shows a simple example. The first column fires off a Google search for the linked content. Never wonder what the Acer Aspire Notebook is again.

Rather than linking to an external site, the third column links to another Mode report. When you click on a cell in the third column, the link—which takes advantage of Mode's auto-run feature—opens a second report, sets the device name parameter, and automatically executes the query.

Looks like you've got a thing for cutting-edge data news.

Get the latest.