I created a random set of data, it changes each time you run the report so good for testing. It adds 50 to all the values so we know we will never get a zero (for testing).
I used the following dataset query
DECLARE @t TABLE (ReferralWeek date, RefCnt int)
INSERT INTO @t VALUES
('2020-06-21', 50+(rand()*500)), ('2020-06-21', 50+(rand()*500)), ('2020-06-07', 50+(rand()*500)), ('2020-06-07', 50+(rand()*500)), ('2020-03-29', 50+(rand()*500)),
('2020-06-21', 50+(rand()*500)), ('2020-05-03', 50+(rand()*500)), ('2020-05-24', 50+(rand()*500)), ('2020-06-14', 50+(rand()*500)), ('2020-04-12', 50+(rand()*500)),
('2020-04-19', 50+(rand()*500)), ('2020-04-12', 50+(rand()*500)), ('2020-06-21', 50+(rand()*500)), ('2020-04-26', 50+(rand()*500)), ('2020-06-21', 50+(rand()*500)),
('2020-04-19', 50+(rand()*500)), ('2020-06-07', 50+(rand()*500)), ('2020-05-10', 50+(rand()*500)), ('2020-06-21', 50+(rand()*500)), ('2020-05-10', 50+(rand()*500)),
('2020-05-31', 50+(rand()*500)), ('2020-06-14', 50+(rand()*500)), ('2020-05-17', 50+(rand()*500)), ('2020-04-12', 50+(rand()*500)), ('2020-04-26', 50+(rand()*500)),
('2020-05-03', 50+(rand()*500))
SELECT * FROM @t
I then created a new report, added line chart, set values to SUM(RefCnt)
and Category Group to ReferralWeek
.
Next I right-clicked the Category Group and chose "properties" from here I could see the name was "Chart1_CategoryGroup"
. This is the scope expression we will need to calculate the vertical axis range.
Next I right-click the vertical axis and chose "properties".
I set the interval type to "number" and then set the expressions for the min and max values to the following...
=MIN(SUM(Fields!RefCnt.Value, "Chart1_CategoryGroup"))
and
=MAX(SUM(Fields!RefCnt.Value, "Chart1_CategoryGroup"))
Note we used the category group name as the scope name.
This gets us part of the way but the interval has to be calculated too or the highest number wont; be show on the axis, so if he highest number was 605 then the axis might show 600 with the last point slightly above it.
We can fix this by calculating the interval. It might not 100% with this simple example but should be close enough.
The interval was set to the following expression.
=(
MAX(SUM(Fields!RefCnt.Value, "Chart1_CategoryGroup"))
-
MAX(SUM(Fields!RefCnt.Value, "Chart1_CategoryGroup"))
)
/ 10
You can adjust how many labels you want by adjusting the '10' divisor.
This gives us the following
BEWARE!
By using the smooth line chart and depending on the data, your curve may now fall off the bottom of the chart. Within your requirements, there is nothing you can do other than add some padding to the minimum value or switch to a non-smoothed chart.
Here's an example of what you might get. (the beauty of a random number generator for testing ! )