Index: remit/finance_core/reporting.py
===================================================================
--- remit/finance_core/reporting.py	(revision 13e7c01b660cce664c1e5dd05f2fed24c272a1a1)
+++ remit/finance_core/reporting.py	(revision 162f5272145ca8cefd8fb3b555e26311850a18d2)
@@ -1,4 +1,5 @@
 from decimal import Decimal
-from django.db.models import Sum
+from django.db.models import Q, Sum
+import finance_core.models
 
 def build_table_annotate(line_items, main_lineitem_limit_primary, primary_axis, primary_axis_objs, secondary_axis, ):
@@ -7,5 +8,5 @@
     table = []
     zero = Decimal('0.00')
-    for num, (pk, label, qobj, ) in enumerate(primary_axis):
+    for num, (pk, label, qobj, objrel_qobj) in enumerate(primary_axis):
         arcprimary[pk] = num
         table.append([zero]*len(secondary_axis))
@@ -17,5 +18,5 @@
     # Do the real work
     print secondary_axis
-    for num, (label, qobj_lineitem, qobj_primary) in enumerate(secondary_axis):
+    for num, (pk, label, qobj_lineitem, qobj_primary) in enumerate(secondary_axis):
         print num
         secondary_results = (primary_axis_objs.filter(main_lineitem_limit_primary, qobj_primary, ).annotate(Sum('lineitem__amount')))
@@ -37,10 +38,53 @@
     table = [ # Primary axis
             [ # Secondary axis
-                total_amount(line_items.filter(primary[2], secondary[1]))
+                total_amount(line_items.filter(primary[2], secondary[2]))
             for secondary in secondary_axis]
         for primary in primary_axis]
 
     return table
-    
 
 build_table = build_table_annotate
+
+
+def get_primary_axis(slug, base_area):
+    if slug == 'budget-areas':
+        return get_budget_areas(base_area)
+    else:
+        raise UnsupportedOperationException()
+
+def get_secondary_axis(slug, base_area):
+    if slug == 'budget-areas':
+        return get_budget_areas(base_area)
+    elif slug == 'layers':
+        return get_layers(base_area)
+    else:
+        raise NotImplementedError
+
+def get_budget_areas(base_area):
+    name = 'Budget Areas'
+    base_area_depth = base_area.depth
+    axis = [
+        (
+            area.pk,
+            area.indented_name(base_area_depth),
+            Q(budget_area=area),
+            Q(lineitem__budget_area=area),
+        )
+        for area in base_area.get_descendants()
+    ]
+    axis_objs = base_area.get_descendants()
+    return name, axis, axis_objs,
+
+def get_layers(base_area):
+    name = 'Layers'
+    axis = [
+        (
+            finance_core.models.layer_num(layer),
+            finance_core.models.layer_name(layer),
+            Q(layer=finance_core.models.layer_num(layer)),
+            Q(lineitem__layer=finance_core.models.layer_num(layer)),
+        )
+        for layer in finance_core.models.layers
+    ]
+    return name, axis, None,
+
Index: remit/finance_core/views.py
===================================================================
--- remit/finance_core/views.py	(revision 13e7c01b660cce664c1e5dd05f2fed24c272a1a1)
+++ remit/finance_core/views.py	(revision 162f5272145ca8cefd8fb3b555e26311850a18d2)
@@ -32,28 +32,31 @@
         base_area_obj = finance_core.models.BudgetArea.get_by_path(['Accounts'])
     line_items = line_items.filter(budget_area__in=base_area_obj.get_descendants())
-    base_area_depth = base_area_obj.depth
-    #print base_area_obj
 
     # Initialize the axis
-    primary_name = 'Budget Areas'
-    primary_axis = [
-        (area.pk, area.indented_name(base_area_depth), Q(budget_area=area), ) for area in base_area_obj.get_descendants()
-    ]
-    primary_axis_objs = base_area_obj.get_descendants()
-    secondary_name = 'Layers'
-    secondary_axis = [
-        (
-            finance_core.models.layer_name(layer),
-            Q(layer=finance_core.models.layer_num(layer)),
-            Q(lineitem__layer=finance_core.models.layer_num(layer)),
-        )
-        for layer in finance_core.models.layers
-    ]
-    secondary_axis.append(('Total', Q(), Q()))
+    # Primary
+    if 'primary' in request.REQUEST:
+        primary_slug = request.REQUEST['primary']
+    else:
+        primary_slug = 'budget-areas'
+    try:
+        primary_name, primary_axis, primary_axis_objs = finance_core.reporting.get_primary_axis(primary_slug, base_area_obj, )
+    except NotImplementedError:
+        raise Http404("Primary axis %s is not implemented" % primary_slug)
+
+    # Secondary
+    if 'secondary' in request.REQUEST:
+        secondary_slug = request.REQUEST['secondary']
+    else:
+        secondary_slug = 'layers'
+    try:
+        secondary_name, secondary_axis, secondary_axis_obj = finance_core.reporting.get_secondary_axis(secondary_slug, base_area_obj, )
+    except NotImplementedError:
+        raise Http404("Secondary axis %s is not implemented" % secondary_slug)
+    secondary_axis.append((None, 'Total', Q(), Q()))
 
     primary_labels = [ ]
-    for num, (pk, label, qobj, ) in enumerate(primary_axis):
+    for num, (pk, label, qobj, objrel_qobj, ) in enumerate(primary_axis):
         primary_labels.append(label)
-    secondary_labels = [ secondary[0] for secondary in secondary_axis ]
+    secondary_labels = [ secondary[1] for secondary in secondary_axis ]
 
     # Do the computation
