I have a table like this:
+----+--------+------------+----------+
| ID | Item | Date | Category |
+----+--------+------------+----------+
| 1 | xyz | 3/12/2013 | A |
| 2 | xyz | 3/23/2013 | A |
| 3 | j423 | 4/19/2013 | C |
| 4 | 9d98df | 4/16/2013 | B |
| 5 | j423 | 5/13/2013 | C |
+----+--------+------------+----------+
I want to group the data in columns both by Date
(by month) and by Category
, like so:
3/2013 | 4/2013
Item A | B | C | A | B | C
xyz | | | | |
j423 | | | | |
9d98df | | | | |
I know that I can group the data by having a function that returns the date as month/year and then pivot on the month field, and I can create a composite-key field with, e.g.
select item, getMonth(date) & category as month_category from myTable
and then pivot on month_category
to give me:
Item A_3/2013 | B_3/2013 | C_3/2013 | A_4/2013 | B_4/2013 | C_4/2013
xyz | | | | |
j423 | | | | |
9d98df | | | | |
But this won't give me a report where I have the two layers of columns shown above. Is there a way to do this in Access? Or am I stuck with the composite column names?