2 rows of column headers
I need to recrearte an old legacy report in RS that lists customer sales history for 24 months. The tricky part is that the corresponding month columns of each year need to be on top of each other:
[customer] [Jan 2008] [Feb 2008] [Mar 2008]
[Jan 2009] [Feb 2009] [Mar 2009]
Cust1 $4,000 $4,500 $4,800
$4,600 $4,900 $3,800
Cust2 $2,000 $2,500 $1,800
$1,700 $4,100 $3,300
Any direction or inoput on how to approach this would be appreciated.
February 28th, 2011 12:48pm
Hi Just check if the below helps:
I created a sample table :
select * from temp_table
Cust Sales
Month Year
Month_Year
Cust1
1000 1
2009 Jan 2009
Cust1
1200 2
2009 Feb 2009
Cust1
1300 1
2010 Jan 2010
Cust1
1400 2
2010 Feb 2010
Cust2
2000 1
2009 Jan 2009
Cust2
2200 2
2009 Feb 2009
Cust2
2300 1
2010 Jan 2010
Cust2
2400 2
2010 Feb 2010
Then use the pivot :
SELECT *
FROM (
SELECT Cust,
year [Year],
Month [Month],
sales
FROM temp_table
) TableDate
PIVOT (
SUM(sales)
FOR [Month] IN (
[1],[2]
)
) PivotTable
order by cust
you will get below result set:
Cust Year 1 2
Cust1 2009 1000 1200
Cust1 2010 1300 1400
Cust2 2009 2000 2200
Cust2 2010 2300 2400
Plug in this quey in the report. The change you will have to make to the report will be to add expression to populate the columns. Let me know if this helps.
Free Windows Admin Tool Kit Click here and download it now
February 28th, 2011 5:31pm
Hi I have a simple solution for this request .Just take 3 or 4 simple steps and I think it will really help you.
1. Just take a Matrix from Toolbox
2. drag and drop SalesAmount(which have sale amount of customer e.g 100) column to Data of Matrix
3. After that drag and drop Month_Year(which have month- year value for a customer e.g [Jan 2008] ) column to 'columns' of Matrix
4. After that drag and drop CustmerName(which have Customer name e.g Cust1 ) column to 'Rows' of Matrix.
Let me know if this helps you or not.
Cheers!!!
Sumit GureCheers!! Sumit
March 1st, 2011 1:02am
Hi,
If the 24 months data is static, you can use matrix. If so, you can add an additional row to column header, and add one year to its value (because it will always display
the early 12 month in the new row). You can refer to my report as an example:
http://cid-854fa6d2b7d88cc7.office.live.com/self.aspx/Work/2RowsOfColumnHeaders.rdl
If you have any other question, please feel free to ask.
Thanks,
Albert Ye
Free Windows Admin Tool Kit Click here and download it now
March 9th, 2011 8:35am