In this article, we are going to look at ways to create metrics in physical or virtual data sets.
Introduction
Metrics allow you to compute any value based on one or more fields within a given dataset. Metrics can be added in either physical or virtual dataset (that combines one or more physical datasets)
For example, we can have the below metric calculated
The total number of students who have received scholarships greater than 4500 and have at least have a high school certificate.
Let's learn how to create metrics :
Step 1 : Edit the dataset as shown below :
Step 2: Once you click on Edit, go to Metrics and Click on ADD ITEM
Step 3 : Add Metric, Label , and SQL Expression as shown below
SQL Expression :
((sum(case when ("status"='Graduated' and "Education Level" in ('University/College', 'High School') and ("Scholarship Amount")::FLOAT >4500)
This SQL Expression calculates the total number of students who are at least High School Graduates and have received Scholar Amount >4500
Step 4 : Save the dataset.
Now you can use this metric to create charts while using this dataset.
While creating the chart, this metric is available in SAVED METRIC for any future calculations (without having to recalculate) as shown below :