1

I need to create a dimensional environment for sales analysis for a retail company.

The hierarchy that will be present in my Sales fact is:

1 - Country
1.1 - Region
1.1.1 - State
1.1.1.1 - City
1.1.1.1.1 - Neighbourhood
1.1.1.1.1.1 - Store
1.1.1.1.1.1.1 - Section
1.1.1.1.1.1.1.1 - Catgory
1.1.1.1.1.1.1.1.1 - Subcatgory
1.1.1.1.1.1.1.1.1.1 - Product

Metrics such as Number of Sales, Revenue and Medium Ticket (Revenue / Number of Sales) makes sense up to the Subcategory level, because if I reach the Product level the agreggation composition will need to change (I guess).

Also, metrics such as Productivity, which is Revenue / Number of Store Staff, won't make sense to existe in this fact table, because it only works up to the Store level (also, I guess).

I'd like to know the best solution resolve this question because all of it are about Sales, but some makes sense until a specifict level of my hierarchy and others don't.

Waiting for the reply and Thanks in advance!

4

1 回答 1

2

您应该将层次结构拆分为 2 个维度,商店和产品

Stores维度是关于销售地点的,你可以把员工数量放在这个维度

Store_Key  STORE    Neighbourhood    City  Country  Num_Staff
1          Store1   4th Street       LA       US    10
2          Store2   Main Street      NY       US    2

产品尺寸看起来像

Product_Key  Prod_Name       SubCat   Category     Unit_Cost
1            Cheese Sticks   Diary    Food         $2.00
2            Timer           Software Computing    $25.00

您的事实表有每个销售的记录,并与上述维度相关

Store_Key  Product_Key  Date      Quantity  Tot_Amount
1          1            31/7/2014   5         $10.00   (store1 sells 5 cheese)
1          2            31/7/2014   1         $25.00   (store1 sells 1 timer)
2          1            31/7/2014   3          $6.00   (store2 sells 3 cheese)
2          2            31/7/2014   1         $25.00   (store2 sells 1 timer)

现在您的数据已经到位,您可以使用您的报告工具来获取您需要的度量。示例 SQL 如下所示

SELECT store.STORE, 
       SUM(fact.tot_amount) as revenue, 
       COUNT(*) as num_sales
       SUM(fact.tot_amount) / store.NumStaff as Productivity
FROM tbl_Store store, tb_Fact fact
WHERE fact.Store_key = store.Store_key
GROUP BY store.STORE

应该返回以下结果

STORE    revenue    num_sales    Productivity
Store1   $35.00     2            3.5
Store2   $31.00     2            15.5
于 2014-07-31T03:09:14.977 回答