Link to home
Start Free TrialLog in
Avatar of SQLSearcher
SQLSearcher

asked on

SSRS Chart data and selections with no entries

Hello Experts Exchange
I am developing a SSRS Report that has categories and a sum of Total hours.  I select the data, that is OK, but I have categories that have no data against them but I want them to show up on the chart as a zero value.

I have a table of data that lists all the categories.

Is there a way I can select the categories that have no data for them and set the value to zero and still keep my categories with data too?

Regards

SQLSearcher
Avatar of Nico Bontenbal
Nico Bontenbal
Flag of Netherlands image

I suppose the data is in a SQL Server database. I think the easiest way is to use an outer join in your query to make sure all the categories are always returned in your dataset (with a zero value, if there is no data). This can be done with an outer join. See:
http://technet.microsoft.com/en-us/library/ms187518(v=sql.105).aspx
Avatar of SQLSearcher
SQLSearcher

ASKER

Hello Nicobo
This is the SQL I have, but its not working as there is one category that is not coming back as zero.

SELECT   a.[Category], Isnull(SUM(b.[Total Lost Hours]),0) AS [Total Lost Hours]
FROM  [dbo].[MachineLosses_Level1] a       
left outer join MachineLosses_New b on a.[Category] = b.[level 1]
WHERE     ([File Name] IN ('Htr01 (581)', 'Htr04 (584)', 'Htr3 (583)', 'Htr9 (589)', 'UKL (593)'))
GROUP BY a.[Category]
ORDER BY [Total Lost Hours] DESC

Open in new window


Can you see where my error is?

Regards

SQLSearcher
ASKER CERTIFIED SOLUTION
Avatar of Nico Bontenbal
Nico Bontenbal
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you very much for your help.