How to Use What-If Analysis in Looker
Your Looker dashboard is brilliant at showing you what happened last quarter, but what about planning for the next one? Static reports only tell part of the story, leaving you to guess how future changes might affect your outcomes. This article will show you how to transform your Looker reports from historical records into interactive forecasting tools by building a what-if analysis.
What is "What-If" Analysis (and Why You Should Bother)
What-if analysis is exactly what it sounds like: a way to see the potential outcome of a situation if a specific variable changes. Instead of only looking at historical data - like your sales revenue last month - you can create interactive models to answer forward-looking questions. It’s the difference between asking "How did we do?" and asking "How would we do if...?"
This method shifts your mindset from being reactive to being proactive. It allows you and your team to run different scenarios on the fly, directly within a Looker dashboard, without having to mess with spreadsheets or ask a data analyst to re-run a report ten different times.
Here are a few common business questions you can answer with a what-if model:
For Marketing: “What would our return on ad spend (ROAS) be if we increased our ad budget by 20% while assuming a 5% drop in conversion rate?”
For Sales: “How would our total revenue change if the team’s average deal size increased by 15%?”
For E-commerce: “What is the projected revenue next quarter if we can boost our average order value (AOV) by $10?”
For Operations: “How many new support tickets can we expect if our user base grows by 25% next month?”
Building this capability turns your BI tool into a strategic planning partner, empowering anyone on your team to make more informed decisions based on potential futures, not just past events.
Foundation: Key Looker Concepts You'll Need
To build a what-if analysis in Looker, you'll need a basic understanding of a few components within Looker’s modeling layer, LookML. You don’t need to be a LookML expert, but knowing what these pieces do is helpful.
LookML Projects
LookML is the language Looker uses to describe dimensions, aggregates, calculations, and data relationships in your database. All your logic lives inside a LookML "project." We'll be adding a few lines of code to one of our project's "view" files. A view file typically corresponds to a single table in your database.
Parameters
Parameters are the engine of what-if analysis. A parameter in LookML creates an interactive filter-only field on your dashboard or Explore. Unlike a standard filter that narrows down existing data, a parameter is a flexible input box where a user can enter any value - like a percentage increase, a target number, or a cost assumption. It doesn’t filter the query directly, instead, its value can be referenced in other calculations to make them dynamic.
Liquid Templating
Liquid is an open-source templating language developed by Shopify, and Looker has integrated it into LookML to enable more dynamic content. When working with parameters, you'll use Liquid to grab the value that a user inputs into the parameter field and inject it into your calculations (measures or dimensions). Its syntax is straightforward, usually involving double curly braces like {{ value }}. We will use a special Liquid syntax for Looker: {% parameter parameter_name %}.
How to Build Your What-If Analysis in Looker: A Step-by-Step Guide
Let's walk through building a common scenario: modeling a change in e-commerce revenue based on a projected increase in Average Order Value (AOV).
Our goal is to create a field where a user can input a percentage, say "10%," and immediately see a "Projected Revenue" column recalculated based on that increase. We'll assume you already have an orders view file with existing measures for total_revenue and order_count.
Something like this may already exist in your LookML orders.view file:
Step 1: Create a Parameter in Your View File
First, open the LookML view file where your base logic lives (in this case, probably orders.view.lkml). At the bottom of the file (or alongside other parameters if you have any), add a parameter field. This code creates a field labeled "Projected AOV Increase (%)" that will appear as a text box in your Explore.
A few notes on this code:
parameter: This declares the field as a parameter.aov_increase_percentage: This is the unique name for your parameter that we will reference later.type: number: This tells Looker that users can only input numerical values.label: This is the user-friendly name that will appear in the Looker UI fields list and filter section.
Step 2: Calculate Your Baseline AOV
To project a new revenue number, we first need to calculate our baseline Average Order Value. We can do this by creating a new measure that divides total revenue by the number of orders. Add this new measure to your orders.view.lkml file.
We use NULLIF(${order_count}, 0) to avoid any "divide by zero" errors in the database.
Step 3: Build Your Dynamic "What-If" Measure
Now it's time to connect our parameter to a calculation. We'll create two new measures: one to calculate the "Projected AOV" and another to calculate the "Projected Total Revenue." This is where we use Liquid to reference the user's input from the aov_increase_percentage parameter.
Add the following code to your orders.view.lkml file:
Let's break down the logic in projected_aov:
It starts with our baseline
average_order_valuemeasure.Then it multiplies it by
(1 + {% parameter aov_increase_percentage %} / 100.0).The
{% parameter aov_increase_percentage %}tag dynamically inserts whatever number the user types into our parameter box. If a user types "15" into the box, this expression becomes(1 + 15 / 100.0), or1.15.The
projected_total_revenuesimply multiplies the newprojected_aovby the total number of orders.
After saving your LookML changes (and pushing to production if you're in development mode), it’s time to see it in action.
Step 4: Using Your What-If Analysis in an Explore
Go to the Explore associated with your orders data. In the field picker on the left, you should now see your newly created fields:
Projected AOV Increase (%)
AOV (Baseline)
Projected AOV
Projected Total Revenue
The parameter will show up both in the list of dimensions and as an available filter, as defined by label in our parameter.
Here’s how to use it:
Select your measures: Add
AOV (Baseline),Projected AOV,Total Revenue, andProjected Total Revenueto your report.Add a filter: Find "Projected AOV Increase (%)" in the fields list and click the "Filter" button. This will add your parameter to the filters section at the top of the Explore.
Enter a value: In the filter box for "Projected AOV Increase (%)", type a number. Start with
10. By default, you'll need to enter a value, otherwise, the projection won't run correctly. If nothing is provided, it can throw an SQL error for an incomplete calculation depending on your setup. So, it's best to always provide some numerical input. You can add adefault_valueto LookML with a string of what you want your numerical entry to default to, if necessary. For this, type10into the parameter we created.Run the query: Click "Run".
You’ll now see your results. The "AOV (Baseline)" and "Total Revenue" columns will show your historical data, while the "Projected AOV" and "Projected Total Revenue" columns will show the recalculated numbers based on a 10% increase. Change the input value to 25, -5, or 50 and re-run to immediately see a different scenario.
Step 5: Add Your Model to a Dashboard for Everyone to Use
The real power of what-if analysis comes from making it accessible to team members who don't live in LookML or the Explore UI.
Create a Look or open an existing visualization with all your baseline and projected measures.
Make sure you have added the "Projected AOV Increased (%)" to your Filter logic for that specific Visualization or Look. Remember your new visualization will not have results if you have yet to populate those query results in the input filter of the query's backend interface. You can set up your parameter filter's numerical string input right next to your filter by clicking on the advanced section as you normally do for filters in your look.
Save the look to a new or existing dashboard.
On the dashboard, find your "Look" tile and navigate to your
Filtersat the top of your dashboard. Choose the correct "Projected AOV Increase (%)" filter. Be sure that the filter "listens" to this specificlooktile by hovering over the drop-down menu of yourlook, where your filter setting is on the visualization box itself or tile. Hover over 'Listen to Filters:` drop-down option on the edit feature on the visualization's settings, and set it accordingly.Choose a dashboard filter and input setting, such as a checkbox, button, or dropdown. There are various ways to show user input for viewers.
Now, anyone who has access to the dashboard can input their own values and see the projections update in real-time, bringing self-service data discovery to a whole new level.
Final Thoughts
By using parameters in LookML, you can turn otherwise static reports into powerful, interactive tools for scenario planning. This gives your entire team the ability to model potential business outcomes directly within a dashboard, leading to better strategic conversations and more data-informed decisions.
Building these models in Looker is hands-down a game-changer but still requires navigating LookML. For those who want powerful reporting without the learning curve, this kind of accessible analysis is exactly why we built Graphed. We connect directly to your sources like Google Analytics, Shopify, and Salesforce and let you use plain English to build dashboards and get answers to complex questions, simplifying the entire process from data connection to insight.