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!

1 Like

You can use the following:


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.

1 Like

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_Nawrot linked above, so you can fork it and modify them as you see fit.

1 Like

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!