question

sanjeevarora avatar image
sanjeevarora asked

Creating Line Graph in VS2010 report

I have a table with date fetched from SQL. I would like to plot line graph with month on x axis (bottom) and values division wise (4-5 lines) as per data on y. please advise how to select the category, data field and series to get desired grap![alt text][1]h [1]: /storage/temp/2655-sql-graph-help.jpg
ssrsreporting-servicesreport-viewer
sql-graph-help.jpg (116.1 KiB)
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

GPO avatar image
GPO answered
First thing is to get your data into shape. A line chart in SSRS needs a value column (revenue in your case), columns for "category groups" (the x axis). You'll probably want this to be time (a column for months and one for years will do nicely). Finally you'll want (probably) one column for series groups. I think you're referring to these as divisions. By the look of the table above, I don't think you have your data structured for this at the moment. I have mocked up a quick and dirty query based on AdventureWorksDW2012 as an example. SELECT shd.EnglishMonthName AS ship_month ,shd.CalendarYear AS ship_year ,dst.SalesTerritoryCountry AS sales_country ,max(shd.FullDateAlternateKey) AS mth_sort --Just a way to get the various countries to have different amounts. This is really unconvincing demo data. ,sum(CASE WHEN dst.SalesTerritoryCountry = 'Australia' THEN frs.SalesAmount WHEN dst.SalesTerritoryCountry = 'Canada' THEN frs.SalesAmount + 200 WHEN dst.SalesTerritoryCountry = 'France' THEN frs.SalesAmount + 450 WHEN dst.SalesTerritoryCountry = 'Germany' THEN frs.SalesAmount + 710 ELSE 0 END ) AS sales_amount FROM dbo.FactResellerSales frs JOIN dbo.DimDate shd ON frs.ShipDateKey = shd.DateKey JOIN dbo.DimSalesTerritory dst ON frs.SalesTerritoryKey = frs.SalesTerritoryKey WHERE shd.CalendarYear = '2006' AND dst.SalesTerritoryCountry ]]]]]]
chart-data.png (7.5 KiB)
chart.png (23.8 KiB)
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

sanjeevarora avatar image
sanjeevarora answered
I am getting the data with following qry. screen capture of data is attached and desired graph (which I am not getting thru report viewer in VS2010). please help.![alt text][1] SELECT div_name = (SELECT div_name FROM Div_Master d WHERE d .Div_Id = x.Div_Code), sbu_name = (SELECT sbu_name FROM Mst_SBUMaster s WHERE s.SBU_Id=x.SBU_Code), * FROM (SELECT Div_Code, SBU_Code, datename(MONTH, Years) AS mon, Amount FROM trn_Expense where SBU_Code like '%' and Div_Code like '%' and [dbo].[fnGetFinYear](Years) like '2015-16') AS s PIVOT (sum(amount) FOR mon IN (April, May, June, July, August, September, October, November, December, January, February, March)) AS x [1]: /storage/temp/2674-line-graph-help.jpg

line-graph-help.jpg (164.7 KiB)
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.