Using and editing explorations

Objectives: in this exercise we will learn how to filter a query, create a metric, create a calculated metric and use the chart formatting options. In this article we will learn about:

Filtering a query

In this exercice we want to :

Add the amount of payment paid with Gift cards per month

Start by duplicating the initial tile from the training dashboard, then:

  1. Replace the measure "Number of orders" with "Total payment amount"

  2. Add a filter on the query editor: Payment method equals gift card

Great, now we can see the amount paid each week by gift card. However, having a filter at the chart level is not optimal as it does not allow other users to easily re-use this metric.

Creating a filtered metric

We will create a new metric corresponding to the payments with gift card:

  1. Edit your exploration by clicking on "Edit in workbench"

  2. Create a new metric under the payment table

    1. The metric should be a sum of the column "amount"

    2. Filter on payment method gift_card

    3. Give your metric a name: Payments with gift card

    4. Set the metric type as number, and add $ as a suffix

Now we can add our new metric to our chart and run the query. We can see that the two measures are displayed, but are equals.

This is because we still have the filter at the chart level. Let's remove it and run the query again: now we can see both the total payment amount and the total payment amount by gift card side by side.

Creating a calculated metric

Now imagine we want to add the percentage of payment made by gift card on our chart. To do so :

  1. go to the exploration edition page in the workbench

  2. click on the + sign next to Payment in the left side panel

  3. click on Add a calculated metric

  4. In the formula editor, type :

Payments with gift card / Total payment amount

Give your metric a name, for example : %age of payment amount with gift card, and set the type as percentage in the advanced settings. Save your metric. Now add this metric to the chart and click on run query.

The metric is added to our chart, but is too small to be visible. In order to fix, we will need to edit our chart options.

Formatting our chart

In the right panel:

  1. Toggle "labels" to display labels

  2. Enable the right axis

  3. Assign the % of gift card payment to this right axis, and change it's type to Area

Last updated