Chris Clarke
Chris Clarke

Reputation: 21

SSRS 2008 Calculated Chart X-Axis Interval

I am trying to create a chart where the interval on the X-axis will redefine itself depending on the 2 time parameters I have set up for the report; I have a @StartTime and a @StopTime. If the difference between the dates is one day, I want the graph axis to show a mark at each whole hour during that day. But any more than a day then the interval can be automatically determined by the program.

I have manually set the difference between the 2 parameters to be 1 day and set the interval and interval type to "24" and "hours", respectively, which gives me the desired results.

I have tried the following function for the interval:

=IIf(DateDiff("d",Parameters!StartTime.Value,Parameters!StopTime.Value)=1, "24", "Auto")

And I have tried the following function for the interval type:

=IIf(DateDiff("d",Parameters!StartTime.Value,Parameters!StopTime.Value)=1, "Hours", "Auto")

I created 2 random textboxes into which I inserted these functions to test if the functions are actually working, and they are. So I can't figure out why the functions won't execute properly when inserted into the interval properties fields.

Why is this not displaying the desired outcome?

Upvotes: 1

Views: 988

Answers (2)

podiluska
podiluska

Reputation: 51494

Instead of using the text "Auto", use a Nothing to represent Auto.

eg:

=IIf(DateDiff("d",Parameters!StartTime.Value,Parameters!StopTime.Value)=1, 24, Nothing)

Upvotes: 1

Randall
Randall

Reputation: 1521

If I recall correctly, you can't change the the axis type at render, which seems like what your trying to do. Honestly I think this might be a case for cheating, make the chart twice, one for each axis type you want, and then conditionally hide them based on a similar Iif statement to the ones you have above.

Other thoughts, 24 is not the interval you want, interval is how much of the x-axis is displayed as tic marks. 1 means 1 tic for every 1 value, 2 means every other one, and 24 if it works would be showing every 24th value (haven't tried it). You want a number interval with a type of hour and an interval of 1 because you want to show every hour. You'll also have to change your x axis to:

=datepart(hour, Fields!YourDateTime.Value)

Otherwise the numbers axis type won't work. You can use similar expressions to create day over day time comparisons. Anyway, good luck!

Upvotes: 0

Related Questions