Analyzing sales and locations of pizzerias based on data from the ClickHouse® database and Marketplace
- Getting started
- Step 1. Import geolayers from the Marketplace
- Step 2. Create a connection
- Step 3. Configure the dataset fields
- Step 4. Create a column chart
- Step 5. Create a bar chart
- Step 6. Create an indicator chart
- Step 7. Create a map chart
- Step 8. Create a dashboard
- Step 9. Add geolayers to the dashboard
- Optional
We will use a ClickHouse® database connection and the Companies: supply and demand product from Marketplace as a source.
In this tutorial, you will prepare a dashboard for selecting locations to open new Dodo pizzerias.
With DataLens, you will analyze locations based on real data:
- Revenue from current Dodo pizzerias.
- Search queries to pizzerias by location (Yandex data).
- Number of all pizzerias by location (Yandex data).
This use case is also available as a video tutorial
To visualize and explore data, set up DataLens and follow the steps below:
- Import geolayers from the Marketplace.
- Create a connection.
- Configure the dataset fields.
- Create a bar chart.
- Create a line chart.
- Create an indicator chart.
- Create a map chart.
- Create a dashboard.
- Add geolayers to the dashboard.
Getting started
To get started with DataLens:
- Log in
to your Yandex account. If you do not have an account, create one. - Open the DataLens home page
. - Click Open DataLens.
- Confirm that you have read the Terms of use
and click Log in.
-
Log in
to your Yandex account. -
Open the DataLens home page
. -
Click Open DataLens.
-
Select one of the options:
-
If you already have an organization, select it from the drop-down menu in the Organizations tab and click DataLens.
Note
To activate a DataLens instance, the user must have the
admin
orowner
role. For more information about roles, see Access management in Yandex Cloud Organization. -
If you have a cloud but no organization, click Add new DataLens. In the window that opens, enter your organization's name and description and click Create organization and DataLens. For more information about working with organizations, see Getting started with organizations.
-
If you have any technical questions about the service, contact Yandex Cloud support
Step 1. Import geolayers from the Marketplace
-
Go to DataLens Marketplace
. -
Choose the Geolayers category and the Companies: supply and demand product.
-
Click Expand in the product card that opens.
-
Save your purchase in the Purchases folder.
-
Click Open.
-
The window that opens will display the following DataLens objects: connection, dataset, chart, and dashboard. Click the yellow dashboard icon at the end of the list.
-
Examine the dashboard and its description at the bottom of the screen:
- Demand is the number of search queries made by users of Yandex geoservices to the selected category of companies or services. The category is determined from the query. Local queries from mobile devices within a search radius of 3 km are included.
- Supply is the number of existing companies in the selected category. This is based on company data in the Yandex Business Directory
.
-
Select the Pizzeria category and check the map for Demand, Supply, and Demand for supply per city measures.
Step 2. Create a connection
- Go to DataLens
. - In the left-hand panel, select
Connections and click Create connection. - Select the ClickHouse connection.
-
In the window that opens, specify the connection parameters:
- Connection type: Specify manually.
- Host name:
rc1a-g1gicp3imcc0pnsg.mdb.yandexcloud.net,rc1b-vbbl6tob599tr3oi.mdb.yandexcloud.net,rc1d-qf1ven1igeihhbep.mdb.yandexcloud.net
(comma-separated). - HTTP interface port:
8443
(default). - Username:
datalens-marathon-2020-11-ro
. - Password:
/4b+xBF6aSCgN9wKTevYGuDjxC9IO4Fa
.
-
Check the connection and click Create connection.
-
Enter
DODO Con
for the connection name and click Create.
-
Wait for the connection to be saved.
Step 3. Configure the dataset fields
-
In the window that opens, click Create dataset.
-
In the new dataset, move the
marathon-2020-11.DODO_opendata
table to the workspace. -
Open the Fields tab.
-
Rename the Name field to Pizzerias in the Name column.
-
For the Coordinates field, select the
geopoint
type. -
For the Revenue field, select the Sum aggregation type in the Aggregation column.
-
Duplicate the Pizzerias field. Click
and select Duplicate. -
Rename the created field from Pizzerias to The number of pizzerias.
-
For the The number of pizzerias field, select the Unique count aggregation type in the Aggregation column.
-
Click Add field.
-
Create a calculated field with the revenue ranking:
- Formula:
RANK([Revenue])
. - Field name: Rank by revenue.
This field will be used when creating charts filtered by TOP-N.
- Formula:
-
Click Create.
-
In the top-right corner, click Save. In the window that opens, specify the DODO dataset name and click Create.
-
Step 4. Create a column chart
-
Click Create chart on the workspace panel of the DODO dataset.
-
In the window that opens, select the OpenDate dimension in the X section and The number of pizzerias in the Y section.
The chart will show statistics on how many new pizzerias opened on a certain day.
-
Set up the Opening dates grouping by month.
- Click the calendar icon in the OpenDate field.
- In the Grouping list, select Rounding → Month.
- Click Apply.
- Click the calendar icon in the OpenDate field.
-
Click Save in the top-right corner. Name the chart as Opening dynamics and click Save.
Step 5. Create a bar chart
-
Select a different chart type: Bar chart.
-
Add the Pizzerias dimension to the Y section. Remove the OpenDate dimension from the Y section.
-
Add the Revenue metric to the X section. Remove the The number of pizzerias metric from the X section.
-
Add the Revenue measure to the Sorting section.
-
Add the Rank by revenue measure to the Filters section:
- Select Less than or equal to from the Operation list.
- Enter 10 in the Value field.
- Click Apply filter.
-
The chart will show the Top 10 pizzerias in Russia.
-
In the top-right corner, click
→ Save as. Name the chart as Top 10 pizzerias and click Save.
Step 6. Create an indicator chart
-
Select the Indicator chart type.
-
Delete the RANK by revenue measure from the Filters field.
-
Add the Revenue measure to the Measure section.
-
In the top-right corner, click
→ Save as. Name the chart as Revenue and click Save. -
Delete the sum(Revenue) measure from the Measure section.
-
Add the The number of pizzerias measure to the Measure section.
-
In the top-right corner, click
→ Save as. Name the chart as The number of pizzerias and click Save.
Step 7. Create a map chart
-
Select Map for chart type.
-
Add the Coordinates dimension to the Geopoints section.
-
Add the Revenue metric to the Size and the Colors sections.
-
Add the following to the Tooltips section:
- Pizzerias
- Address
- OpenDate
- Revenue
-
Go to the Colors section settings.
- Select the Two-color gradient type and the Yellow (shades) color.
- Click Apply.
-
Save the chart as Pizzerias on the map.
Step 8. Create a dashboard
-
Go to DataLens
. -
Click Create dashboard.
-
In the window that opens, click Add in the top-right corner and select Chart.
-
Select the chart named The number of pizzerias.
-
Click Add.
-
Repeat steps 4-6 for the other charts.
-
For indicator charts (The number of pizzerias and Revenue), disable the name display. To do this, disable the Show option in the Tab settings window.
-
To prevent charts from being created as a single column, drag each chart to any free space in the dashboard.
-
In the top-right corner, click Add → Selector.
- In the window that opens, select the DODO dataset.
- In the selector settings:
- Activate the Show option to display the name.
- Select the City field.
- Click Add.
-
Move the selector to the top. You can resize the charts if necessary.
-
Save the dashboard:
- In the top-right corner, click Save.
- Enter DODO Dashboard as the dashboard name and click Create.
-
Choose Moscow in the selector. If the map focus remains at the same location when changing the city in the filter, refresh the page in your web browser. DataLens captures the map scale and location if you change them during the current session.
Step 9. Add geolayers to the dashboard
-
Make sure that you only selected Moscow in the city filter of your dashboard.
-
Click the menu icon in the top-right corner of the map.
-
Select Edit.
-
Click on the DODO dataset name and choose Add dataset.
-
In the drop-down list, select Datasets instead of Personal folder.
-
Select Organizations (dataset imported from Marketplace in Step 1).
-
Once the dataset is selected, the link setup window appears. By default, a link is established between fields with the same names.
-
Click Add link.
-
Add a link between the City (DODO) and City (Organizations) dataset fields and click Save.
-
-
Click Save to close the Links window.
-
In the layer section, rename Layer 1.
- To do this, click the layer and select
.
- In the Layer settings window that opens, enter DODO as the name and click Apply.
- To do this, click the layer and select
-
Click
to add another layer. Rename it to Demand for supply. -
Change the geolayer type from Points to Polygons.
-
Make sure that the current dataset is Organizations rather than DODO. If the current dataset is DODO, click its name in the top-left corner and choose Organizations.
-
Add the Polygon dimension to the Polygons section.
-
Add the Polyogn.Type dimension to the Filters section and set it to hash7. Click Apply filter.
-
Add the Category dimension to the Layer filters section and choose Pizzeria. Click Apply filter.
-
Add the Demand for supply per city measure to the Colors section.
-
In the color settings, select the Blue-Grey-Red three-color gradient and click Apply.
-
Change the transparency level to 60.
-
Add the following to the Tooltips section:
- Demand
- Supply
- Demand for supply per city
- Top queries
- Top companies
-
Click Save in the top-right corner.
-
Go back to the dashboard (it should be open on the previous tab in your browser) and refresh the web page.
-
Choose Saint Petersburg in the selector. After that, the dashboard, including the map and external geolayer, will only be filtered by this selector.
If the map focus remains at the same location when changing the city in the filter, refresh the page in your web browser. DataLens captures the map scale and location if you change them during the current session.
Optional
Here are some ideas you might want to work on by yourself:
- Adding a geolayer with businesses from the Where to eat category (restaurants and fast food chains in general, not only pizzerias).
- Adding the Audience: interests and social demographics
product from the Marketplace to display the city audience data on the map in a similar way. - You can use the city of Voronezh as an example to study the free geolayers by Geointellect
. The demo set offers calculated indexes representing the location's business potential for fast food.
ClickHouse® is a registered trademark of ClickHouse, Inc