Example #1
0
customers_data_set = DataSet(entity=customer_entity, name='Customers')

customers_data_set.exclude_path([('Order', 'First order'), 'Customer'])
customers_data_set.exclude_path([('Order', 'Last order'), 'Customer'])

customers_data_set.include_attributes(['Zip code'],
                                      ['Zip code', 'City', 'State'])
customers_data_set.include_attributes([('Order', 'First order')],
                                      ['Order date'])
customers_data_set.include_attributes([('Order', 'Last order')],
                                      ['Order date'])

customers_data_set.add_simple_metric(
    name='# Orders (lifetime)',
    description='Number of orders placed by this customer',
    aggregation=Aggregation.SUM,
    column_name='number_of_orders_lifetime')

customers_data_set.add_simple_metric(
    name='Revenue (lifetime)',
    description='The lifetime revenue generated from products purchased by this customer',
    aggregation=Aggregation.SUM,
    column_name='revenue_lifetime',
    important_field=True)

customers_data_set.add_composed_metric(
    name='AOV',
    description='The average revenue per order of the customer',
    formula='[Revenue (lifetime)] / [# Orders (lifetime)]')
Example #2
0
order_items_data_set.add_simple_metric(
    name='# First orders',
    description='The number of first orders (orders with an invoice)',
    column_name='is_first_order_id',
    aggregation=Aggregation.DISTINCT_COUNT)

order_items_data_set.add_simple_metric(
    name='Product revenue',
    description='The price of the ordered products as shown in the cart',
    aggregation=Aggregation.SUM,
    column_name='product_revenue')

order_items_data_set.add_simple_metric(
    name='Shipping revenue',
    description='Revenue generated based on the delivery fee',
    aggregation=Aggregation.SUM,
    column_name='shipping_revenue')

order_items_data_set.add_composed_metric(
    name='Revenue',
    description='The total cart value of the order',
    formula='[Product revenue] + [Shipping revenue]',
    important_field=True)

order_items_data_set.add_composed_metric(
    name='AOV',
    description=
    'The average revenue per order. Attention: not meaningful when split by product',
    formula='[Revenue] / [# Orders]')
Example #3
0
sellers_data_set.exclude_path([('Order', 'First order'), 'Customer'])

sellers_data_set.include_attributes(['Zip code'],
                                    ['Zip code', 'City', 'State'])

sellers_data_set.include_attributes(['Order'], ['Order date'])

sellers_data_set.add_simple_metric(
    name='# Orders (lifetime)',
    description='Number of orders with at-least one product fulfilled by this seller',
    aggregation=Aggregation.SUM,
    column_name='number_of_orders_lifetime')

sellers_data_set.add_simple_metric(
    name='# Order items (lifetime)',
    description='Number of products sold by this seller',
    aggregation=Aggregation.SUM,
    column_name='number_of_order_items_lifetime')

sellers_data_set.add_simple_metric(
    name='Revenue (lifetime)',
    description='The lifetime revenue generated from products sold by this seller',
    aggregation=Aggregation.SUM,
    column_name='revenue_lifetime',
    important_field=True)

sellers_data_set.add_composed_metric(
    name='AOV',
    description='The average revenue per order. Attention: not meaningful when split by product',
    formula='[Revenue (lifetime)] / [# Orders (lifetime)]')