[Yandex Cloud documentation](../../index.md) > [Yandex Object Storage](../index.md) > [Tutorials](index.md) > Visualizing Yandex Query data

# Visualizing Yandex Object Storage data in Yandex DataLens


By integrating Yandex Query with Yandex DataLens, you can visualize data stored in Yandex Object Storage. DataLens generates a YQL query, while Yandex Query runs it and returns the results, which are visualized using charts.

For the solution architecture, see below.

![datalens-architecture](../../_assets/datalens/data-lens-architecture.png)

As an example, let's visualize how the number and average cost of New York City yellow taxi rides depend on the time of day. The data was pre-uploaded to a public Yandex Object Storage bucket named `yq-sample-data`, in the `nyc_taxi_csv` folder.

{% note info %}

Yandex Cloud provides the **New York City taxi trips** dataset as is. Yandex Cloud makes no representations, explicit or implicit, warranties, or conditions pertaining to your use of the specified dataset. To the extent allowed by your local laws, Yandex Cloud shall not be liable for any loss or damage, including direct, consequential, special, indirect, incidental, or exemplary, resulting from your use of the dataset.

NYC Taxi and Limousine Commission (TLC):

The data was collected and provided to the NYC Taxi and Limousine Commission (TLC) by technology providers authorized under the Taxicab & Livery Passenger Enhancement Programs (TPEP/LPEP). The taxi trip data is not generated by the TLC, and the TLC makes no representations whatsoever about the accuracy of this data.

Take a look at the [dataset source](https://www1.nyc.gov/site/tlc/about/tlc-trip-record-data.page) and its [terms of use](https://www1.nyc.gov/home/terms-of-use.page).

{% endnote %}

To visualize and explore data, [set up your cloud](#before-you-begin) and follow these steps:

1. [Connect to the data in Object Storage](#create_connection).
1. [Create a connection in Yandex DataLens](#create_connection_lens).
1. [Configure the dataset fields](#create_dataset).
1. [Configure visualization](#create_comdo_chart).

## Getting started {#before-you-begin}

Sign up for Yandex Cloud and create a [billing account](../../billing/concepts/billing-account.md):
1. Navigate to the [management console](https://console.yandex.cloud) and log in to Yandex Cloud or create a new account.
1. On the **[Yandex Cloud Billing](https://center.yandex.cloud/billing/accounts)** page, make sure you have a billing account linked and it has the `ACTIVE` or `TRIAL_ACTIVE` [status](../../billing/concepts/billing-account-statuses.md). If you do not have a billing account, [create one](../../billing/quickstart/index.md) and [link](../../billing/operations/pin-cloud.md) a cloud to it.

If you have an active billing account, you can create or select a [folder](../../resource-manager/concepts/resources-hierarchy.md#folder) for your infrastructure on the [cloud page](https://console.yandex.cloud/cloud).

[Learn more about clouds and folders here](../../resource-manager/concepts/resources-hierarchy.md).

{% note info %}

To create a DataLens connection to Yandex Query, you will need a [service account](../../iam/concepts/users/service-accounts.md) with the `editor` [role](../../iam/operations/sa/assign-role-for-sa.md) for the folder where you will create the Object Storage [bucket](../concepts/bucket.md) [connection](#create_connection).

{% endnote %}

## Connect to the data in Object Storage {#create_connection}

1. In the [management console](https://console.yandex.cloud), select the folder where you want to create a [connection](../../query/concepts/glossary.md#connection).

   ![select-catalog](../../_assets/datalens/yandex-query-visualization/select-catalog.png)

1. Navigate to **Yandex Query**.

   ![select-yq](../../_assets/datalens/yandex-query-visualization/select-yq.png)

1. In the left-hand panel, select ![study](../../_assets/console-icons/graduation-cap.svg) **Tutorial**.
1. Click **Create connection**. In the **Create connection** section, all the parameter fields are pre-filled. Just enter an optional description and click **Create**. You will see the screen for creating a data [binding](../../query/concepts/glossary.md#binding).
1. Enter the optional data binding description and click **Create**. This will create the resources required for this tutorial.

## Create a connection in Yandex DataLens {#create_connection_lens}

To create a Yandex Query connection:

1. Go to the DataLens [home page](https://datalens.ru/?skipPromo=true).
1. In the left-hand panel, select ![image](../../_assets/console-icons/thunderbolt.svg) **Connections** and click **Create connection**.
1. Select the **Yandex Query** connection.
1. Configure the connection as follows:

   * **Cloud and folder**: Select the folder with your service account.
   * **Service account**: Select an existing [service account](../../iam/concepts/users/service-accounts.md) or create a new one.
   * **Cache TTL in seconds**: Specify the cache TTL or leave the default value.
   * **Raw SQL level**: Select **Allow subqueries from datasets and queries from charts**.

1. Click **Create connection**.
1. Enter `yq-connect` as your connection name and click **Create**.

## Configure the dataset fields {#create_dataset}

1. In the top-right corner of the page where you created the connection, click **Create dataset**.

   ![create-dataset](../../_assets/datalens/yandex-query-visualization/create-dataset.png)

1. In the window that opens, enter the query text below and click **Create**.

   ```sql
   SELECT 
       *
   FROM 
       bindings.`tutorial-analytics`
   ```

   If the configuration is correct, the **Preview** section at the bottom of the screen will contain the following data:

   ![dataset-results](../../_assets/datalens/yandex-query-visualization/datalens-dataset-results.png)

1. Create a calculated field with the pick-up time data:

   1. Navigate to the **Fields** tab and click **Add field**.

      ![create-field](../../_assets/datalens/yandex-query-visualization/create-field.png)

   1. In **Field name**, specify `hour_trip`.
   1. In the formula line, enter:

      ```sql
      HOUR([tpep_pickup_datetime])
      ```

   1. Click **Create**. The new `hour_trip` field will appear in the list of dataset fields.

1. In the **Aggregation** column, select the **Average** aggregation type for the `total_amount` field.

   ![field-agg](../../_assets/datalens/yandex-query-visualization/field-agg.png)

1. In the top-right corner, click **Save**. Enter `yellow-taxi-dataset` for the dataset name and click **Create**.
1. Once the dataset is saved, click **Create chart** in the top-right corner.

   ![create-chart](../../_assets/datalens/yandex-query-visualization/create-chart.png)

## Configure visualization {#create_comdo_chart}

To visualize and analyze the data, use a [combined](../../datalens/concepts/chart/index.md) [chart](../../datalens/visualization-ref/combined-chart.md).

1. Select **Combined chart** as the visualization type.

   ![chart-type](../../_assets/datalens/yandex-query-visualization/chart-type.png)

1. Drag the `hour_trip` dimension to the **X** section. The dimension in the **X** section will be shared by all layers.
1. For the first layer, select **Bar chart**.

   ![select-layer-column](../../_assets/datalens/yandex-query-visualization/select-layer-column.png)

1. Drag the `total_amount` measure to the **Y** section. You will see a bar chart in the visualization area.
1. Add a layer by clicking ![plus](../../_assets/console-icons/plus.svg) next to the first layer's name.
1. For the second layer, select **Line chart**.

   ![select-layer-line](../../_assets/datalens/yandex-query-visualization/select-layer-line.png)

1. Add a field to the chart:

   1. At the top left, click ![plus](../../_assets/console-icons/plus.svg) and select **Field**.

      ![chart-add-field](../../_assets/datalens/yandex-query-visualization/chart-add-field.png)

   1. In the window that opens:

      * Under **Field name**, enter `count_trip`.
      * In the formula line, enter `COUNT()`.

        ![chart-field-create](../../_assets/datalens/yandex-query-visualization/chart-field-create.png)

   1. Click **Create**.

1. Drag the new `count_trip` measure to the **Y2** section. You will see a line chart on top of the first chart in the visualization area.
1. In the top-right corner, click **Save**. Enter `yellow-taxi-combo-chart` as the chart name and click **Save**.

The chart you created shows how the number of trips (line chart) and the average ride cost (bar chart) depend on the time of day.

![datalens-yq-combo-chart](../../_assets/datalens/yandex-query-visualization/datalens-yq-combo-chart.png)

Similarly, you can build additional [charts](../../datalens/operations/chart/create-chart.md) and [dashboards](../../datalens/operations/dashboard/create.md) or [share the results](../../datalens/concepts/datalens-public.md) with your teammates.