Question

Using results from one look as a filter for another

  • 20 September 2018
  • 1 reply
  • 326 views

I have created a look, with a calculation that extracts a certain amount of characters (VIN numbers). I need to take those VINs and put them into another look. Is there any possibly way to automate using the results of the calculation as a filter for the other look?


1 reply

Userlevel 7
Badge +1

Hey Naseha!


This is totally possible to do in an automated fashion using the Looker API. In this example, let’s say the VIN numbers are in Look 1, and you want to pass them into Look 2 as filters.


As a general workflow, you’ll want to:




  1. Hit the run look endpoint with 1 as your look_id, to get the list of VIN numbers.




  2. Store that result set somewhere as an array or list




Now you have 2 options-- You can stick to looks, or move to queries. The first option is to…


3a. Hit the update_look endpoint and pass that VIN array to the filters of look 2.


4a. Hit the run look endpoint with 2 as your look_id to get the final result of your newly filtered look


OR


3b. Hit the get_look endpoint and extract the query portion of the response


4b. Edit the query json to include your updated filters list


4c. Hit the run_inline_query endpoint and pass in your updated query json to execute your newly filtered query.


This can be done in any language, but we have API examples in Ruby and Python. Before you dive into actually coding it, you might want to check out the interactive API docs on your instance and try out each of those commands manually, to get a feel for the process.


I think that should get you well on your way! If you write up a script to do this, post it up here! I bet other users will be interested to see it as well 🙂


If anyone’s already done this in a different/better way, feel free to overrule me and share your method!

Reply