---
title: "Tutorial: Build a visual data prep"
description: "Build your first Lakeflow Designer visual data prep with the Wanderbricks sample data: add sources, filter, join, aggregate, check results, and write a Unity Catalog table."
canonical_url: https://docs.databricks.com/aws/en/designer/build-transformation
---

# Tutorial: Build a visual data prep

In this tutorial, you build a visual data prep in Lakeflow Designer that answers a business question: which types of vacation rental property earn the most from confirmed bookings? You use the [Wanderbricks sample dataset](https://docs.databricks.com/aws/en/discover/wanderbricks-dataset.md), a simulated travel booking platform that's preloaded in every Unity Catalog-enabled workspace.

You learn how to:

* Add data sources to the canvas.
* Filter, join, aggregate, and sort data with built-in operators.
* Check each step's results in the output pane.
* Write the results to a Unity Catalog table.

## <a id="prerequisites" />Prerequisites

* A Databricks workspace with Unity Catalog enabled.
* `CAN USE` permission on at least one general purpose compute resource (serverless or all-purpose).
* `USE CATALOG`, `USE SCHEMA`, and `CREATE TABLE` privileges on a schema where you can write the output table, such as `main.default`.

## <a id="create" />Step 1: Create a visual data prep

1. Click ![Plus icon.](https://docs.databricks.com/aws/en/images/product-icons/PlusIcon.svg) **New** in the sidebar and select **Visual data prep**. Designer opens with a welcome screen.
2. Click the file name at the top of the editor and rename the file to `Wanderbricks revenue`.
3. In the compute picker next to the **Schedule** button, select the compute to use.

## <a id="add-bookings" />Step 2: Add the bookings data

Every visual data prep starts with one or more data sources, which the **Source** operator represents on the canvas.

1. On the welcome screen, click **Browse all data**.
2. In the table selector, search for `samples.wanderbricks.bookings` and select the table. A Source operator for the table appears on the canvas.
3. Select the Source operator. The output pane at the bottom of the editor shows a preview of the bookings data, including the `property_id`, `total_amount`, and `status` columns.

You can also drag a table from the **Catalog** pane onto the canvas to add it as a source. For other ways to bring in data, see [Ingest data into Lakeflow Designer](https://docs.databricks.com/aws/en/designer/ingest-data.md).

## <a id="filter" />Step 3: Keep only confirmed bookings

1. Hover over the bookings Source operator and click the ![Plus icon.](https://docs.databricks.com/aws/en/images/product-icons/PlusIcon.svg) button next to it. Select **Filter**. The new Filter operator is already connected to the source.
2. In the Filter configuration pane, add a condition: select the `status` column, select **Is equal to**, and enter `confirmed`.
3. Click **Apply**.
4. Select the Filter operator and check the output pane. The **Included** output contains only confirmed bookings.

The Filter operator has two outputs. **Included** holds the rows that meet the condition, and **Excluded** holds the rest. See [Filter](https://docs.databricks.com/aws/en/designer/built-in-operators.md#filter).

## <a id="join" />Step 4: Join bookings to properties

Each booking has a `property_id`. To group bookings by property type, join them to the `properties` table.

1. Add a second Source operator for `samples.wanderbricks.properties`. In the **Operators** pane, click **Source**, then search for and select the table.
2. In the **Operators** pane, click **Join** to add a Join operator.
3. Connect the **Included** output of the Filter operator to the Join operator's first input. Then connect the properties Source operator to the Join operator's second input. To connect two operators, drag from an output port to an input port.
4. In the Join configuration pane, set the join condition to match `property_id` in both tables.
5. For **Join type**, select **Inner join** to produce a single joined output.
6. Click **Apply**, then select the Join operator to preview the joined rows.

For more about connecting operators, see [Connect operators](https://docs.databricks.com/aws/en/designer/interface.md#connect).

## <a id="aggregate" />Step 5: Total the revenue by property type

1. Click the ![Plus icon.](https://docs.databricks.com/aws/en/images/product-icons/PlusIcon.svg) button next to the Join operator and select **Aggregate**.
2. Under **Aggregate by**, add two aggregations:
   * Select `total_amount`, select `SUM`, and name the output column `total_revenue`.
   * Click **+ Add aggregation**. Select `booking_id`, select `COUNT`, and name the output column `booking_count`.
3. Under **Group by**, select `property_type`.
4. Click **Apply**.

## <a id="sort" />Step 6: Sort the results

1. Click the ![Plus icon.](https://docs.databricks.com/aws/en/images/product-icons/PlusIcon.svg) button next to the Aggregate operator and select **Sort**.
2. Select `total_revenue` and **DESC**, then click **Apply**.

## <a id="check" />Step 7: Check the results

Select the Sort operator. The output pane shows one row for each property type, with the highest-earning type first.

By default, previews process a sample of the input rows, so the totals reflect only that sample. To see totals for the full dataset, click **Run all** in the toolbar. On the full dataset, the results show four property types, with **Urban Year-Round** earning the most revenue. To inspect the distribution of a column, select it and open the data profile. See [Preview and refine results in Lakeflow Designer](https://docs.databricks.com/aws/en/designer/preview-results.md).

## <a id="output" />Step 8: Write the results to a table

1. Click the ![Plus icon.](https://docs.databricks.com/aws/en/images/product-icons/PlusIcon.svg) button next to the Sort operator and select **Output**.
2. In the Output configuration pane, select **Table** for **Output type**.
3. Enter `wanderbricks_revenue_by_property_type` for **Table name**, and select the catalog and schema for **Output location**, such as `main.default`.
4. Leave **Write mode** set to **Overwrite**.
5. Click **Run**. Designer runs the visual data prep and creates the table.

Your finished visual data prep reads two tables, filters and joins them, totals revenue by property type, and writes the result to Unity Catalog.

## <a id="genie-code" />Optional: Try it with Genie Code

You can also build visual data preps by describing what you want. In a new visual data prep, use the Genie Code prompt above the canvas.

> [!TIP]
>
> Tell [Genie Code](https://docs.databricks.com/aws/en/genie-code/index.md) to do this for you:
>
> ```
> Using samples.wanderbricks.bookings and samples.wanderbricks.properties, show total revenue and booking count by property type for confirmed bookings, highest revenue first.
> ```

Genie Code adds and connects the operators for you. Select each operator to check its configuration and results. See [Use Genie Code in Lakeflow Designer](https://docs.databricks.com/aws/en/designer/genie-code.md).

## <a id="next-steps" />Next steps

* To run the visual data prep on a schedule, see [Schedule as a job](https://docs.databricks.com/aws/en/designer/production.md#schedule).
* To make the visual data prep reusable across environments, see [Use parameters in Lakeflow Designer](https://docs.databricks.com/aws/en/designer/parameters.md).
* To learn every part of the editor, see [The Lakeflow Designer interface](https://docs.databricks.com/aws/en/designer/interface.md).
* To explore all of the operators you can use, see [Built-in operators in Lakeflow Designer](https://docs.databricks.com/aws/en/designer/built-in-operators.md).
