# Generate a dynamic index based on user-defined weighted variables

## **Context**

<div align="left"><figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FhB2W9xXbzzo0kEuXMe3S%2Fintermediate%20banner.png?alt=media&#x26;token=4acd2cc7-c7e8-46c0-9669-6f6b73c030dd" alt="Intermediate difficulty banner" width="175"><figcaption></figcaption></figure></div>

In this tutorial, we'll explore how to create a versatile web map application using Builder, focusing on the dynamic customization of index scores through SQL Parameters. You'll learn how to normalize variables using Workflows and how to craft an index based on these normalized variables. We'll guide you through dynamically applying specific weights to these variables, enabling the index to flexibly align with various user scenarios.

Whether it's for optimizing location-based services, fine-tuning geomarketing strategies, or diving deep into trend analysis, this tutorial provides you with the essential tools and knowledge. You'll gain the ability to draw significant and tailored insights from intricate geospatial data, making your mapping application a powerful asset for a wide range of scenarios.

## **Step-by-Step Guide:**

In this guide, we'll walk you through:

* [**Creating normalized variables with Workflows**](#creating-normalized-variables-with-workflows)
* [**Creating an Index Score using normalized variables**](#creating-an-index-score-using-normalized-variables)&#x20;
* [**Enabling SQL Parameters for user-defined index customization**](#enabling-sql-parameters-for-user-defined-index-customization)

***

### Creating normalized variables with Workflows

1. Access *Workflows* from your CARTO Workspace using the Navigation menu.

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FQUq8t7s5Xdk1XU91yfZg%2Fimage.png?alt=media&#x26;token=605e406d-5513-4016-95eb-e4d4df006242" alt=""><figcaption></figcaption></figure>

2. Select the data warehouse where you have the data accessible. We'll be using the CARTO Data Warehouse, which should be available to all users.

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FCfRvuZA4d0pbggVFnTlr%2Fimage.png?alt=media&#x26;token=fcbf3d54-021e-4898-b526-b0901733c35d" alt=""><figcaption></figcaption></figure>

3. In the Sources section location on the left panel, navigate to *demo\_data > demo tables* within CARTO Data Warehouse. Drag and drop the below sources to the canvas.&#x20;
   * `usa_states_boundaries`
   * `derived_spatialfeatures_usa_h3res8_v1_yearly_v2`
   * `cell_towers_worldwide`

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2F128PSUemwvYpYoW27eV5%2Fimage.png?alt=media&#x26;token=a4041159-a950-44fa-b89b-3adb070eb1fd" alt=""><figcaption></figcaption></figure>

4. We are going to focus our analysis in California. To extract California boundary, we add the **Simple Filter** component into the canvas and we connect *USA States Boundary* source to its input. Then, in the node configuration panel we select 'name' as column, 'equal to' as the operation, and 'California' as the value. We click on "Run". You can use the *Map Preview* to visualize the output.

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FR5eOp1z5AHCOxX7WRmUw%2Fimage.png?alt=media&#x26;token=f5d01d20-3162-4fb5-9bf1-5b88f3754227" alt=""><figcaption></figcaption></figure>

5. We are going to leverage spatial indexes, specifically H3 at resolution level 8, to generate our dynamic, weighted index. After isolating the California state boundary, our next step is to transform it into H3 cells. Add the **H3 Polyfill** component to the canvas and set the resolution to level 8 in the node. Then, proceed by clicking 'Run' to complete the transformation.

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2F7F9pV5LNrP8nEDaQDPhY%2Fimage.png?alt=media&#x26;token=4e8266b9-6be0-497b-b499-3c9729cb0c88" alt=""><figcaption></figcaption></figure>

6. Now that we have California H3 cells, we can use the **Join** component to select *Derived Spatial Features* source located in California. Add the component to the canvas, link both sources and select 'Inner' as the join type in the node. Then, click on "Run".

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FHQhVRANqQlZwbdP4XGni%2Fimage.png?alt=media&#x26;token=617f8fe4-f8fa-4123-b9e8-8c76960c4fe7" alt=""><figcaption></figcaption></figure>

Now we can begin normalizing our key variables. Normalizing a variable involves adjusting its values to a common scale, making it easier to compare across different datasets.

7. Prior to normalizing, we will use the **Select** component to keep only the necessary columns using the below expression:&#x20;

```sql
h3, 
population_joined as population, 
retail_joined as retail, 
transportation_joined as transport, 
leisure_joined as leisure
```

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FrWgHdZA3jEss9LyoPYl6%2Fimage.png?alt=media&#x26;token=b83ef379-0c16-4835-8e67-4468b48648ef" alt=""><figcaption></figcaption></figure>

8. Now, let's normalize our desired variables. To do so, add the **Normalize** component to the canvas. In the node, select one of the desired variables such `population`. Click on "Run". Once completed, you can visualizes the result in the Data Preview. By inspecting it you can reveal a new column named `population_norm` with data varying from 0 to 1.&#x20;

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FqgSKDio0igp8Pt4aY2g5%2Fimage.png?alt=media&#x26;token=c1d1d146-ca61-4d65-a77c-394e2b2c06d6" alt=""><figcaption></figcaption></figure>

9. Repeat the above process by adding the **Normalize** compoment for each of the remaining variables: `retail`, `leisure` and `transport`.&#x20;

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2Fy6BaC3nwqaUtpVFDLPle%2Fimage.png?alt=media&#x26;token=545bc711-6fa9-4220-989c-99ec86f6b4da" alt=""><figcaption></figcaption></figure>

10. After finishing with the variables from *Derived Spatial Features*, we can start analyzing the distance between each H3 cell and the closest cell tower location. The first step of this analysis is to extract the cell towers located within California state boundary. To do so, we will use the **Spatial Filter** component adding *Cell Towers Worldwide* source as the main input and *California state* as the secondary input. In the node, select 'Intersect' as the spatial predicate.

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2Fsdh35AJgf4MCTupXfkT3%2Fimage.png?alt=media&#x26;token=6363d6dc-0621-497f-9397-61d14ebb3bc9" alt=""><figcaption></figcaption></figure>

11. Then, we need to extract the centroid geometry from the H3 cells so we can perform a point-to-point distance operation. To do so, add the **H3 Center** component to the canvas and link it with H3 Polyfill output as we are only interested on the H3 ids.&#x20;

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FXlcT8e1rHuuCw5sKDbzO%2Fimage.png?alt=media&#x26;token=05363cd3-f5b6-4e5d-ae0f-1916405f9114" alt=""><figcaption></figcaption></figure>

12. Add a unique id to the filtered Cell Tower locations by using **Row Number** component that will add a new column to your table with the row count on it.&#x20;

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FGjEVWk2kach2nSo7YciZ%2Fimage.png?alt=media&#x26;token=27a1b8f4-0a78-4d15-ab03-2fe5b191fe2c" alt=""><figcaption></figcaption></figure>

12. We can now add the **Distance to nearest** component to calculate the closest distance between each H3 cell to the nearest cell tower location in California. Link the H3 Center output as the main source and add the filtered cell tower locations as the secondary input. In the node, set the  configuration as per below image with the distance set to 500 meters. You can use the *Data Preview* to visualise the resulted columns.

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FDA7Q9ZZgUVNRWM8rCtKK%2Fimage.png?alt=media&#x26;token=25b3bda6-cfca-4445-8068-c876deb93354" alt=""><figcaption></figcaption></figure>

13. With the distance calculated, we can normalize our variable. As on previous steps, we will use the **Normalize** compoment to achieve that specifying the column as the `nearest_distance`.

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FE3vt7jQjRLdNa1ae9J42%2Fimage.png?alt=media&#x26;token=d81ec395-809e-40ef-b457-0e379cf055a4" alt=""><figcaption></figcaption></figure>

14. Given that in our case, a higher distance to a cell tower location is considered less favorable, we need to invert our scale so that higher values are interpreted positively. To achieve this, utilize the **Select** component and apply the following statement to reverse the scale, thereby assigning higher values a more positive significance.

```sql
h3,
1 - nearest_distance_norm as nearest_distance_norm, 
nearest_distance
```

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FUUlRCcyjJM1kBvGjuVuR%2Fimage.png?alt=media&#x26;token=070d4b65-4037-4432-93d3-0ebf84496bb6" alt=""><figcaption></figcaption></figure>

15. Let's join the normalized variables using the **Join** component. In the node, set the join type to 'Inner', as we are only interested on those locations where there is a cell tower location with a minimum distance of 500 meters.&#x20;

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FfSxAa00hq6YH35wbeEaP%2Fimage.png?alt=media&#x26;token=ea06f5e6-4bf5-4929-b39a-74867f8eb806" alt=""><figcaption></figcaption></figure>

15. The final step in our analysis is to save our output results as a table. We will use the **Save as Tabl**e component to generate a table from the normalized variables using H3 spatial index and the California state boundary so we can visualize the analysis location. Save both tables within *CARTO Data Warehouse > Organization > Private* and name them as following:
    * California State Boundary: `california_boundary`
    * Normalized variables: `california_normalized_variables`

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FS3RTdZb7AAwRBDjs14w5%2Fimage.png?alt=media&#x26;token=52491027-f5d7-403a-b2a6-66f67e2ded8d" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FzyYA00PnX1oApVyEIfgl%2Fimage.png?alt=media&#x26;token=f6c2cb11-aea3-467a-95b2-5e4c62a52773" alt=""><figcaption></figcaption></figure>

16. Now that the Workflows is done, you can add *Annotations,* edit the component names and organize it so that the analysis is easy to read and share.&#x20;

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2F9pvoIrdmf3ASs01yQFbW%2Fimage.png?alt=media&#x26;token=c39b18dd-15bd-48a3-b08a-f41fbcb2c886" alt=""><figcaption></figcaption></figure>

***

### Creating an Index Score using normalized variables

17. In Workflows, preview the map result of Save as Table component to generate the California Boundary source. Click on "Create map".&#x20;

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FTWrwgMGiBJz4yFX0lVgj%2Fimage.png?alt=media&#x26;token=d9909c92-3018-4389-8a6a-f3a5dffb3810" alt=""><figcaption></figcaption></figure>

18. A map opens with *California Boundary* added as table source. Change the **Map Title** to "*Create index score using normalized variables*" and rename the layer to "Search Area".&#x20;

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FnrEYYq4LbWHhNIjj5aef%2Fimage.png?alt=media&#x26;token=ca3b8c70-a0c0-41e6-9951-4f2647c51e22" alt=""><figcaption></figcaption></figure>

19. Access the Layer panel, `disable` the **Fill Color** and set the **Stroke Color** to `red`, setting the Stroke Width to `1.5`.

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FHwb7QzRgKQP0w0jgxTF4%2Fimage.png?alt=media&#x26;token=cd10e70a-7f92-42e0-bc6a-a29e6627672b" alt=""><figcaption></figcaption></figure>

20. Now, we will add the normalized variables sources.&#x20;
    * Select the *Add source from* button at the bottom left on the page.&#x20;
    * Click on the *CARTO Data Warehouse* connection.
    * Select *Type your own query*.
    * Click on the *Add Source button*.

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2Fe9DVgxbRGHkPh2cQvxVp%2Fimage.png?alt=media&#x26;token=ab3c51b0-8710-4df3-a234-6fde3143322a" alt=""><figcaption></figcaption></figure>

The SQL query panel will be opened.&#x20;

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FQqCs21g4iOQgBSfOKsqU%2Fimage.png?alt=media&#x26;token=e7b81fe2-fba3-4854-9a3c-4b4effe3e331" alt=""><figcaption></figcaption></figure>

21. Enter the following query replacing the qualified table name by your output table created in *Step 15*. You can find this name in the Data Explorer by the navigating to the recently created table. Once the query is updated, make sure the **Spatial Data Type** selected is H3. Then, click on "Run".&#x20;

```sql
SELECT * FROM carto-dw-ac-dp1glsh.private_atena_onboardingdemomaps_ca2c4d8c.califoria_normalized_variables
```

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FQUICmzTG6ppMv6qnGG39%2Fimage.png?alt=media&#x26;token=611737e5-8014-43ce-af14-c1a78b60e18d" alt=""><figcaption></figcaption></figure>

22. Now, rename let's modify the query creating an index score based on the normalized variables we previously generated in Workflows. Update the **SQL query** as per below and click on "Run". Then, rename the Layer to 'Index Score'.

```sql
WITH index AS (
 SELECT 
  	h3,
    population_norm + retail_norm + leisure_norm + transport_norm + nearest_distance_norm_joined as index_score
  FROM carto-dw-ac-dp1glsh.private_atena_onboardingdemomaps_ca2c4d8c.califoria_normalized_variables)
  
SELECT h3,ML.MIN_MAX_SCALER(index_score) OVER() as index_score FROM index
```

After running the SQL query, the data source is updated. Then, you can style your H3 layer by `index_score`, an index that has been calculated considering all variables as equal weights.&#x20;

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FGNDFa3LwzL83xmqcgID5%2Findex1.gif?alt=media&#x26;token=da24d6e5-0966-41a6-be23-5aa66848c678" alt=""><figcaption></figcaption></figure>

While indexes with equal weights offer valuable insights, we'll also explore custom weighting for each variable. This approach caters to diverse user scenarios, particularly in identifying optimal business locations. In Builder, you can apply weights to variables in two ways:

1. **Static Weights**: Here, specific weights are applied directly in the SQL query. These weights are fixed and can only be changed by the Editor. This method is straightforward and useful for standard analyses.
2. **Dynamic Weights**: This more flexible approach involves using [SQL Parameters](https://academy.carto.com/widgets-and-sql-parameters#sql-parameters). It allows Viewer users to adjust weights for each variable, tailoring the analysis to their specific business needs.

Let's begin with the static method:

23. Edit your **SQL query** to include static weights for each normalized variable. Experiment with different weights to observe how they impact the index score. Each time you modify and re-run the query, you'll see how these adjustments influence the overall results.&#x20;

```sql
WITH data_ AS (
  SELECT
  	h3,
  	population_norm * 1 as population_norm,
  	retail_norm * 0.2 as retail_norm,
  	leisure_norm * 0.2 as leisure_norm,
  	transport_norm * 0.6 as transport_norm,
  	nearest_distance_norm_joined * 1 as nearest_distance_norm
  FROM carto-dw-ac-dp1glsh.private_atena_onboardingdemomaps_ca2c4d8c.califoria_normalized_variables),

index AS (
 SELECT 
  	h3,
    population_norm + retail_norm + leisure_norm + transport_norm + nearest_distance_norm as index_score
  FROM data_)
  
SELECT h3,ML.MIN_MAX_SCALER(index_score) OVER() as index_score FROM index
```

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FBnan7BwkbBXjk3DFMs7k%2Fimage.png?alt=media&#x26;token=31c1cad7-4dd2-472e-b092-d431a0d0f253" alt=""><figcaption></figcaption></figure>

***

### Enabling SQL Parameters for user-defined index customization

[SQL parameters](https://academy.carto.com/widgets-and-sql-parameters#using-sql-parameters) are placeholders that you can add in your SQL Query source and can be replaced by input values set by users. In this tutorial, we will learn how you can use them to dynamically update the weights of normalized variables.

24. The first step in this section is to create a **SQL Numeric Parameter.** You can access this by clicking on the top right icon in the Sources Panel.&#x20;

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2Fb443UeWxp8LmHFz8PkNA%2Findex2.gif?alt=media&#x26;token=dba96211-8dc9-442e-8554-69994545f4ec" alt=""><figcaption></figcaption></figure>

25. Set the **SQL Numeric Parameter** configuration as follows:
    * Slider Type: `Simple Slider`
    * Min Value: `0`
    * Default Value: `0.5`
    * Max Value: `1`
    * Display name: `Population Weight`
    * SQL name: `{{population_weight}}`

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FtXYb0zJsJA5Hki2sp7X5%2Fimage.png?alt=media&#x26;token=48bf7287-65f5-4441-9a72-0d0bb224eb7b" alt=""><figcaption></figcaption></figure>

26. Once you create a parameter, a **parameter control** is added to the right panel. From there, you can copy the parameter SQL name to add it to your query. In this case, we will add it as the weight to our `population_norm` column.&#x20;

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FVPEUaq9YTAsgbj4ROxnw%2Findex4.gif?alt=media&#x26;token=4f941182-c33e-4a45-96fc-f35463983dc1" alt=""><figcaption></figcaption></figure>

27. Repeat *Step 26* to add a SQL Numeric Parameter and update the SQL Query for each of the normalized variables: `leisure_norm`, `retail_norm`, `transport_norm` and `nearest_distance_norm` The output SQL query and parameter panel should look similar to the  below.

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2F3NbsSsQceTr2t6CjU5A3%2Fimage.png?alt=media&#x26;token=4be2f208-0e0a-4676-8e02-1549747af769" alt=""><figcaption></figcaption></figure>

```sql
WITH data_ AS (
  SELECT
  	h3,
  	population_norm * {{population_weight}} as population_norm,
  	retail_norm * {{retail_weight}} as retail_norm,
  	leisure_norm * {{leisure_weight}} as leisure_norm,
  	transport_norm * {{transport_weight}} as transport_norm,
  	nearest_distance_norm_joined * {{cell_tower_distance_weight}} as nearest_distance_norm
  FROM carto-dw-ac-dp1glsh.private_atena_onboardingdemomaps_ca2c4d8c.califoria_normalized_variables),

index AS (
 SELECT 
  	h3,
    population_norm + retail_norm + leisure_norm + transport_norm + nearest_distance_norm as index_score
  FROM data_)
  
SELECT h3,ML.MIN_MAX_SCALER(index_score) OVER() as index_score FROM index
```

28. Now, style your map as desired. We will be setting up our **Fill Color** palette to `ColorBrewer RdPu 4` with color based on `index_socre` and changing the **basemap** to `CARTO Dark Matter`. You can test the parameter controls to see how the index is updated dynamically taking into account the input weight values.&#x20;

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FCAypdH8qAfcNt5M3UqAm%2Fimage.png?alt=media&#x26;token=1ea73b7f-bca2-4c23-b0d7-e48ae7dfeccc" alt=""><figcaption></figcaption></figure>

29. Let's add a **description to our map** that can provide viewer users with further context about this map and how to use it.&#x20;

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2F4iNI3eEMHVYE6ZJ0wNtT%2Fimage.png?alt=media&#x26;token=a972e456-b549-4e29-90f9-9023b3eeeb1f" alt=""><figcaption></figcaption></figure>

30. &#x20;In the **Legend** tab, set the legend to open when the map is first loaded.

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FWFxn6sclJPiYtPz4KEsM%2Fimage.png?alt=media&#x26;token=cdb6c1f9-08b5-4412-a606-895a19e9a089" alt=""><figcaption></figcaption></figure>

30. Finally we can make the **map public** and **share** the link to anybody.&#x20;
    * For that you should go to *Share* section on the top right corner and set the map as *Public*.
    * Activate *SQL parameters controls* options so that Viewer users can control the exposed parameters.&#x20;

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FpfOpJTtRrQlYHnDIKsIX%2Fimage.png?alt=media&#x26;token=43148fc3-ddb6-4ac6-8d81-29069bd64991" alt=""><figcaption></figcaption></figure>

30. Copy the public share link and access the map as a Viewer. The end result should look similar to the below:&#x20;

{% embed url="<https://clausa.app.carto.com/map/e88bdb92-8263-44ed-976b-0b5df1dcfc56>" %}
