in10: how to build a metric in a metric

10

Click here to load reader

Upload: petr-olmer

Post on 13-Jun-2015

1.191 views

Category:

Technology


0 download

DESCRIPTION

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

TRANSCRIPT

Page 1: in10: How to build a metric in a metric

in10

Using BY in MAQL

How to builda metric in a metric

with Petr Olmer, GoodData Evangelist

Page 2: in10: How to build a metric in a metric

GoodData in10 with Petr Olmer: How to build a metric in a metric

What is a metric in a metric?

example 1: average monthly revenue

example 2: average number of new leads in a quarter

2

average from monthly numbers

total revenue for each month

average from quarterly numbers

number of new leads for each quarter

There are aggregationson two levels.

inner level (by month)

outer level

In most cases,the aggregations are different.

Exception:average of averages.

Page 3: in10: How to build a metric in a metric

GoodData in10 with Petr Olmer: How to build a metric in a metric

Solution

average monthly revenue

average number of new leads in a quarter

3

average from monthly numbers

total revenue for each month

average from quarterly numbers

number of new leads for each quarter

Monthly Revenue:SELECT SUM(Revenue) BY Close Month/Year

Average Monthly Revenue:SELECT AVG(Monthly Revenue)

Quarterly Leads:SELECT COUNT(Lead) BY Created Quarter/Year

Average Quarterly Leads:SELECT AVG(Quarterly Leads)

Page 4: in10: How to build a metric in a metric

GoodData in10 with Petr Olmer: How to build a metric in a metric

Solution in detail

4

Monthly Revenue:SELECT SUM(Revenue) BY Close Month/Year

Average Monthly Revenue:SELECT AVG(Monthly Revenue)

Outer metric is an aggregation of the inner metric.

Inner metric uses BY to define the aggregation level.

Page 5: in10: How to build a metric in a metric

GoodData in10 with Petr Olmer: How to build a metric in a metric

You need to define the border between the inner aggregation and the outer one.

Why BY?

5

Without BY, the inner SUM would not knowwhere to stop and hand over to the outer AVG.

inner SUM outer AVG

BY Month

Page 6: in10: How to build a metric in a metric

GoodData in10 with Petr Olmer: How to build a metric in a metric

Behind the scenes

6

inner SUM outer AVG

BY Month

$400K

datamart behind the scenesyour

report

Nov 2010 $450K

Dec 2010 $580K

Jan 2011 $320K

Feb 2011 $360K

March 2011 $430K

April 2011 $260K

Page 7: in10: How to build a metric in a metric

GoodData in10 with Petr Olmer: How to build a metric in a metric

Behind the scenes

You’ve asked for one number and that’s what you get:Average monthly revenue

The monthly report is computed but you cannot see it.

7

Nov 2010 $450K

Dec 2010 $580K

Jan 2011 $320K

Feb 2011 $360K

March 2011 $430K

April 2011 $260K

$400K

datamart report behind the scenesyour

report

Page 8: in10: How to build a metric in a metric

GoodData in10 with Petr Olmer: How to build a metric in a metric

Automatic (in-report) BY

You don’t need to use BY when the attribute is in the report.

8

Month/Year Revenue Monthly Revenue

Nov 2010 $450K $450K

Dec 2010 $580K $580K

Jan 2011 $320K $320K

Feb 2011 $360K $360K

March 2011 $430K $430K

April 2011 $260K $260K

Revenue:SELECT SUM(Revenue)

Monthly Revenue:SELECT SUM(Revenue) BY Month/Year

Both metrics return the same numbersbecause Month/Year attribute is in the report.

automatic BY

BY says: Include this attribute in the computation. But it’s already there!

Page 9: in10: How to build a metric in a metric

GoodData in10 with Petr Olmer: How to build a metric in a metric

BY and BY

You can include more than one attribute in the BY clause.

You can have a metric in a metric in a metric in a...

9

SELECT SUM(Revenue) BY Month/Year, Department

It will return a number for each month and department.

Best Region Leads:SELECT MAX(Average Monthly/Region Leads)

Average Monthly/Region Leads:SELECT AVG(Month/Region Leads) BY Region

Month/Region Leads:SELECT COUNT(Lead) BY Month/Year, Region

one number for each month and region

one number for each region

one number only

Page 10: in10: How to build a metric in a metric

GoodData in10 with Petr Olmer: How to build a metric in a metric

Off you go...

Find the border.

Put BY into the inner metric.

10

average from region numbers

total revenue for each region

SELECT SUM(Revenue) BY Region