Alternative to a Right Join in LookML

I am tying to create a viz that displays inventory and sales data per sku for all of our products. As a simple example our data is structured like this:

table Sales that contains sku level data for each order.
table Inventory that contains sku level inventory numbers for every day.
the two tables are joined on sku=sku and date=date

The problem I am running in to is being able to pull Inventory numbers on a day when a sku has no sales.
Since the Sales table is what starts our LookML, if there is a day with no sales then the Inventory table is not able to join on sku=sku.
So for a simple table viz, If i pivot by date and select sku as the dimension, and then bring in Sales and Inventory as measures, on days where there are no sales the inventory also shows 0 since there is no sku to join on.

In SQL I could just “reverse” my query ordering, pull Inventory first and left join to Sales so the Sales columns would be NULL, but due to the way our LookML is written, everything joins off of the Sales table so there is no way to “reverse” the query ordering if that makes sense. Is there an easy fix for this with Looker since Right Joins are not an option? I feel like I am missing something obvious

0 2 2,104
2 REPLIES 2

Hello Chris,

  • Another choice that is similar to ‘Right Join’ would be the join type: full_outer. Just want to confirm that you have seen that option.

  • Also, you describe "reverse"ing your query ordering. It seems that you would be able to re-orient your explore, meaning: make sku the base view, and join to sales from there. But perhaps you cannot do that for other reasons not fully described here.

Interested to hear if those options will work for you. If not, there may be other options, but it would probably be best to understand better why the options above don’t work for you before making other suggestions.

Let us know how it goes!

full_outer didnt work because of the data structure, and re-orienting the explore wasn’t possible unfortunately

I was just able to walk through a solution with our Looker rep where we created a new Explore using a derived table that cross joins skus and dates, then left joined the sales and inventory data - in case anyone else runs in to this issue.

Top Labels in this Space
Top Solution Authors