Upcoming SlideShare
×

# in10: How to build a metric in a metric

1,735 views

Published on

For metrics more complex than simple Total Revenue, you often need to use "BY" in GoodData.

2 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

Views
Total views
1,735
On SlideShare
0
From Embeds
0
Number of Embeds
40
Actions
Shares
0
12
0
Likes
2
Embeds 0
No embeds

No notes for slide

### in10: How to build a metric in a metric

1. 1. in How to build10 a metric in a metric Using BY in GoodData MAQL with Petr Olmer, GoodData Evangelist
2. 2. What is a metric in a metric?example 1: average monthly revenue There are aggregations average from monthly numbers outer level on two levels. total revenue inner level (by month) for each monthexample 2: average number of new leads in a quarter average from quarterly numbers In most cases, the aggregations are different. number of new leads for each quarter Exception: average of averages.in10 with Petr Olmer: How to build a metric in a metric 2
3. 3. Solutionaverage monthly revenue average from monthly numbers Average Monthly Revenue: SELECT AVG(Monthly Revenue) total revenue for each month Monthly Revenue: SELECT SUM(Revenue) BY Close Month/Yearaverage number of new leads in a quarter average from quarterly numbers Average Quarterly Leads: SELECT AVG(Quarterly Leads) number of new leads for each quarter Quarterly Leads: SELECT COUNT(Lead) BY Created Quarter/Yearin10 with Petr Olmer: How to build a metric in a metric 3
4. 4. Solution in detailAverage Monthly Revenue:SELECT AVG(Monthly Revenue) Outer metric is an aggregation of the inner metric.Monthly Revenue:SELECT SUM(Revenue) BY Close Month/YearInner metric uses BY to deﬁne the aggregation level.in10 with Petr Olmer: How to build a metric in a metric 4
5. 5. Why BY?You need to deﬁne the border between the inner aggregation and the outer one. inner SUM outer AVG BY Month Without BY, the inner SUM would not know where to stop and hand over to the outer AVG.in10 with Petr Olmer: How to build a metric in a metric 5
6. 6. Behind the scenes inner SUM outer AVG BY Month Nov 2010 \$450K Dec 2010 \$580K Jan 2011 \$320K \$400K Feb 2011 \$360K March 2011 \$430K April 2011 \$260K your datamart behind the scenes reportin10 with Petr Olmer: How to build a metric in a metric 6
7. 7. Behind the scenes You’ve asked for one number and that’s what you get: Average monthly revenueThe monthly report is computed but you cannot see it. Nov 2010 \$450K Dec 2010 \$580K Jan 2011 \$320K \$400K Feb 2011 \$360K March 2011 \$430K April 2011 \$260K your datamart report behind the scenes reportin10 with Petr Olmer: How to build a metric in a metric 7
8. 8. Automatic (in-report) BYYou don’t need to use BY when the attribute is in the report. Month/Year Revenue Monthly Revenue Revenue: Nov 2010 \$450K \$450K SELECT SUM(Revenue) Dec 2010 \$580K \$580K Jan 2011 \$320K \$320K Monthly Revenue: Feb 2011 \$360K \$360K SELECT SUM(Revenue) BY Month/Year March 2011 \$430K \$430K April 2011 \$260K \$260K automatic BY Both metrics return the same numbers because Month/Year attribute is in the report. BY says: Include this attribute in the computation. But it’s already there!in10 with Petr Olmer: How to build a metric in a metric 8
9. 9. BY and BYYou can include more than one attribute in the BY clause. SELECT SUM(Revenue) BY Month/Year, Department It will return a number for each month and department.You can have a metric in a metric in a metric in a...Best Region Leads: one number onlySELECT MAX(Average Monthly/Region Leads)Average Monthly/Region Leads: one number for each regionSELECT AVG(Month/Region Leads) BY RegionMonth/Region Leads: one number for each month and regionSELECT COUNT(Lead) BY Month/Year, Regionin10 with Petr Olmer: How to build a metric in a metric 9
10. 10. Off you go...Find the border. average from region numbers total revenue for each regionPut BY into the inner metric. SELECT SUM(Revenue) BY Regionin10 with Petr Olmer: How to build a metric in a metric 10