SSRS Empty Chart with DateTimes


I am working with SSRS and having trouble creating a graphical chart to display data. My dataset is very simple, as it only has one column which is a datetime field (known as CreatedOn).

My SQL query is:

SELECT [CreatedOn]
FROM [Incident]
    month, DATEDIFF(month, 0,CURRENT_TIMESTAMP), 0))

My goal is to have the query results show up in a chart and have them grouped by year and by month, as well as sorted. For example, I should be able to see that 40 incidents were created in February 2005. Those 40 incidents would be represented graphically as a single bar (it is a bar graph) with the number 40 on top (or somewhere).

My issue is that either my chart shows up completely blank, or the report fails to run. When it fails to run, the error I receive is:

the value expression for field 'CreatedOn' contains an error: conversion from string 'CreatedOn' to type 'Date' is not valid.

I have tried using SSRS expressions on the CreatedOn field, such as CDate() and FormateDateTime(). That does get the report to run, but the chart shows up blank. I would not think that the field should have to be formatted or converted in SSRS since it is already a datetime field at the database level. I have tried about 10 different combinations of groupings and sorts, but my chart always shows up blank. I have even used CDate() and so forth in the grouping and sort expressions which are a part of the chart.

How can I get my bar chart to work (a.k.a. show datetimes, grouped and sorted)?

I am going to go off the assumption:

  1. You have more data being pulled than just the ‘CreatedOn’ field.

    a. Because if you don't it will be difficult to create a chart as you have nothing else to compare it too.

If this is an accurate assumption here is an example of how to create a chart and have the data formatted by dates.

When designing a chart you need to take a lot into consideration. First I like to ensure that I have as little null data as possible. This causes charts to act wonky (at least from my experience).

Second is how the data will be represented. We have several things to consider when we think about charts and groups. There are Category groups, Series groups, and then the Values.

According to Microsoft: charts have a direct similarity to Matrix’s. They act the same way:

  • The Column groups of a Matrix are similar to that of the Category Groups in a chart.
  • The Row groups of a Matrix are similar to that of the Series Groups in a chart.
  • The Data area of a Matrix is similar to that of the Values Groups in a chart.

Setting Up the chart: If we want the number of Incidents sorted by Year and then Month it might look something like this:

Year by Category (You can use your group by Expression here) =Year(Fields!CreatedOn.Value) Incidents will be in the Values section =Count(Fields!Incidents.Value)

Once you have that working and showing data I would then start adding in the data for the month. Again thinking about how you want to have the data displayed. You could then add a second Grouping on the category under the other one with your month function.

Another Useful link on charts (I know this is a little older but it’s details are still relevant)

*Side Note: When dealing with dates it can be a little tricky especially if SSRS is not recognizing something as a date. Here is a useful link that I have used when dealing with dates. Dates

I hope this helped!