Merging Explores in Looker: A Step-by-Step Guide with an Example

Merging Explores in Looker: A Step-by-Step Guide with an Example

  • Post category:Looker
  • Post last modified:February 8, 2023
  • Reading time:11 mins read

Looker is a powerful business intelligence tool that enables organizations to easily analyze their data. However, sometimes you need to merge data from multiple sources to create a more comprehensive view of your data. In this blog post, we’ll take a look at how to merge two Explores in Looker and the steps involved in doing so.

In Looker, you can merge two Explores by combining the underlying SQL query into a single query that pulls data from both Explores. Here are the steps to merge two Explores:

  1. Create a new Explore or duplicate an existing Explore to serve as the base for the merged query.
  2. Copy the SQL query from each of the Explores you want to merge.
  3. Modify the base query to combine the two queries using a UNION statement.
  4. Save the changes and test the merged query to ensure it returns the desired results.
  5. Update the fields and relationships in the LookML model to reflect the changes in the merged query.

It’s important to note that merging Explores requires a good understanding of SQL and the underlying data structure.

______________________________________________________________________________________________

More Imp Topics

How Looker Writes SQL?

How to calculate percent of total in looker?

Table Calculations in Looker

What are Derived tables in Looker?

How to set conditional formatting in LOOKER?

Looker Interview Questions And Answers

_____________________________________________________________________________________________

Merging Explores in Looker Use Case:

Suppose you work in a retail company and want to analyze sales data. You have two separate Explores, one that tracks sales by region and another that tracks sales by product. In order to get a complete view of your sales data, you need to merge these two Explores into a single Explore that tracks sales by region and product.

Step 1: Create a New Explore or Duplicate an Existing Explore

The first step in merging two Explores is to create a new Explore or duplicate an existing Explore that you want to use as the base for your merged query. To create a new Explore, go to the Looker navigation bar and click on “Explores”. Then, click on “New Explore” and choose the data source for your new Explore.

Alternatively, you can duplicate an existing Explore by going to the Explore’s page, clicking on the “…” button in the upper right corner and selecting “Duplicate”.

Step 2: Copy the SQL Queries from the Two Explores

Next, you need to copy the SQL queries from each of the Explores you want to merge. To do this, go to each of the Explores, click on the “SQL” tab and copy the entire query.

Step 3: Modify the Base Query to Combine the Two Queries

Once you have the SQL queries from both Explores, you need to modify the base query to combine the two queries using a UNION statement. The UNION statement allows you to combine the results of two SELECT statements into a single result set.

Here’s an example of how you might combine the two SQL queries:

SELECT region, SUM(sales) as sales
FROM sales_by_region
GROUP BY region
UNION
SELECT product, SUM(sales) as sales
FROM sales_by_product
GROUP BY product

Step 4: Save the Changes and Test the Merged Query

Once you have modified the base query to combine the two queries, save the changes and test the merged query to ensure it returns the desired results. You can do this by clicking on the “Run” button and reviewing the results in the “Results” tab.

Step 5: Update the Fields and Relationships in the LookML Model

Finally, you need to update the fields and relationships in the LookML model to reflect the changes in the merged query. This is important because Looker uses the LookML model to generate the views, fields, and calculations in your Explore.

To update the fields and relationships in the LookML model, go to the Looker navigation bar and click on “Develop”. Then, select the model that contains your merged Explore and update the fields and relationships as necessary.

Below is an example of a set of queries and their merged results:

Merging results from different Explores

All of the primary query’s fields are displayed in the merged results, using the primary query’s names for the fields. This means that if the primary query and an added query use different names for a matching dimension, only the primary query’s dimension name will be displayed in the results.

“Merged results do not perform an actual SQL join. But, for those who are familiar with SQL joins, the Merged Results feature combines the results of multiple Explores in a similar way as would a left join. The results of the added query are combined with the results of the primary query as if they are being left joined into the primary query.”

Limitations:

While merging Explores in Looker is a powerful feature, it’s important to note that it can have some limitations. Here are a few of the most common limitations to keep in mind:

  • Complex SQL Queries: Merging Explores requires a good understanding of SQL and the underlying data structure. If you’re not familiar with SQL, it’s recommended to consult a database administrator or Looker support before proceeding.
  • Performance: Merging two or more Explores can result in slower query performance, especially if the merged query involves large amounts of data. To mitigate this, you may need to optimize your SQL queries, add indexes, or split the data into smaller chunks.
  • Data Consistency: When merging Explores, it’s important to ensure that the data is consistent and that the combined result set accurately reflects the data in both Explores. This may involve checking and updating the data types, field names, and relationships in the LookML model.
  • Maintenance: Merging Explores requires ongoing maintenance to keep the data up-to-date and ensure that the combined result set remains accurate. This may involve updating the SQL queries, fields, and relationships in the LookML model on a regular basis.

Conclusion:

Merging Explores in Looker is a powerful feature that allows you to create a more comprehensive view of your data. By combining the results of two or more Explores into a single query, you can get a complete picture of your data and make more informed decisions. However, it’s important to understand the limitations and the steps involved in merging Explores, especially if you’re not familiar with SQL. By following the steps outlined in this blog post, you can successfully merge two Explores in Looker and get the most out of your data.

________________________________________________________________________________________________

More Imp Topics

How Looker Writes SQL?

How to calculate percent of total in looker?

Table Calculations in Looker

What are Derived tables in Looker?

How to set conditional formatting in LOOKER?

Looker Interview Questions And Answers

_____________________________________________________________________________________________

Reference :

About Me:-
I am Om Prakash Singh – Data Analytics Consultant , Looker Consultant , Solution Architect .
I am Highly analytical and process-oriented Data Analyst with in-depth knowledge of database types; research methodologies; and big data capture, manipulation and visualization. Furnish insights, analytics and business intelligence used to advance opportunity identification.

You’ve got data and lots of it. If you’re like most enterprises, you’re struggling to transform massive information into actionable insights for better decision-making and increased business results.
Reach out to us if you are interested to evaluate if Looker is right for you or any other BI solution.

Leave a Reply