Create Looker Sankey Diagram

Hi there,
I’d like to create a Sankey Diagram to show flow. Data will be like page views. Users will be directed to 1st page, and then to other pages.

Data:
timestamp, user_id, page_name

How should I properly create Sankey diagram? I found very limited sources online.
Need to know:
1). Is it necessary to prepare data in certain form? If yes, what form does it have to be?
2). How to prepare in LookML

Thanks!

2 10 11.2K
10 REPLIES 10

You can use the following:

looker/custom_visualizations_v2

Contribute to looker/custom_visualizations_v2 development by creating an account on GitHub.


Unfortunately I don’t think there is a lot of active development with this script. It would be awesome if somebody created a new version that works with pivots etc.

Hi Dawid,
Thanks for the resources. I have checked these two articles already, however, i’m still not sure how to create diagram.
I feel the same that there is not a lot of development. So few articles talking about this.

I managed to get a diagram working but don’t think we will actively use it because of lack of working with pivots, tooltips, highlighting whole path across multiple nodes etc.

How far did you get?

Hi!

Here is a quick example of a Sankey diagram setup.

In this example, we are looking at where people who leave San Francisco move to:

To get a Sankey diagram working, you need at least two dimensions and only one measure. For the migration example above, while my explore has four dimensions selected, I am hiding two of them from the visualization:

You can add more dimensions, based on what makes sense about the relationships you are trying to define. In this case, I added migration data from New York County, NY to see the common destinations people leaving New York and San Francisco go to. In this case, I unhid the “origin state” dimension so that now there are three dimensions (origin county, origin state, and destination county)

One thing to be aware of is that the Sankey reflects the order of dimensions as arranged in your “Data” tab. So if you want to see the flow from origin county -> state to destination state-> county, you will need to arrange your fields accordingly:


If you would like more options for configuring Sankey diagrams and are comfortable with javascript and Typescript, we do make the visualizations available in the public repo that @Dawid linked above, so you can fork it and modify them as you see fit.

Yeah. I got the graph. But couldn’t find much options to edit the data. Please help here. If you are using multiple stages, then multiple columns will appear and hence it is becoming difficult to identify which stage belongs to what. Can we just have column header? Requesting your support in this problem

Mihir, could you maybe provide a diagram of what you’d like to see?

Our Sankey custom viz example requires a pretty specific configuration, which Shingi laid out above— If you’re a JS whiz, you could modify it to fit your needs, but I don’t think you’ll get much flexibility out of it as is.

Hi Izzy,

Similar to that added image can we just add the stage name above all the columns we usually have in the Sakey Chart. Maybe for the simplicity purpose, we can take column names from the database as stage names. Please let us know if this is feasible.

Ah, I get it. That functionality doesn’t exist now, but wouldn’t be too hard to add to the custom viz if you do know some javascript. If anyone else feels like giving it a shot, here is the link to the visualization on github: https://github.com/looker/custom_visualizations_v2/tree/master/src/examples/sankey. Would love to see some work done on it!

Hi @Ashton_Du,

I hope you are doing well, check my Sankey diagram created in Excel to visualize user behavior.
 

5fac0e44-9f6a-4156-83e5-71a20d1da870.png


I used ChartExpo™ , It is both an Excel and Google Sheets plugin for data visualization.
There is no requirement of coding skills.
 

Try it for Free:

ChartExpo™ for Excel & Office 365

ChartExpo for Google Sheets

Sharing a video to watch how easy to create Sankey diagram in Google Sheets and Excel.

All the Best!

To create a Sankey Diagram for page views in LookML:

Data Format: Your data should have columns for timestamp, user_id, and page_name. You'll need to aggregate it to track user flow.

Data Preparation in LookML: You can prepare the data in LookML by writing LookML models and explores to extract and organize the required data. Ensure you have dimensions for timestamp, user_id, and page_name in your LookML model.

Once your data is structured properly in LookML, you can use Looker's visualization tools to create the Sankey Diagram.

Top Labels in this Space
Top Solution Authors