Line chart over Column chart in SSRS - reporting-services

I have a column chart with multiple series. (number of series vary from 1-14). X axis is date and Y axis is count.I would like to create a line chart which gives the sum of all series count per date. I tried adding another value of count and changing the chart type to line but the line is drawn with maximum series count per date. Also the label is repeating twice for every series.
Any suggestions on what I am missing?

Here is how I would do it.1. Rollup your Query in SQL - doing this will add a total value for each date as well as a total value for the entire query. Your query would look something like this:
select
YourDate,
YourSeries,
sum(YourCount) YourCount
from YourTable
group by
YourDate,
YourSeries
with rollup
2. Filter out the grand total - the with rollup clause produces a grand total that your chart doesn't need. You can filter this out of the dataset by adding a filter expression =IsNothing(Fields!YourDate.Value), datatype Boolean, value =False3. Set your chart values visibility - set the column values visibility to =IsNothing(Fields!YourSeries.Vale) and the line chart values visibility to =Not(IsNothing(Fields!YourSeries.Vale). Now, your chart and series legend will only show the daily columns and the total line.4. Put the total line chart on a secondary axis This is optional, but since the date totals will be much greater than each series/date value, it will keep the columns from shrinking so small.
It should look something like this:

Related

Calculating average in SSRS Matrix Table alongside filtered columns to separate out current versus previous years

I have a dataset, returned from a SQL query, that has the following data:
TYPE_CODE
YEAR
The data set spans the years 2014 through 2019. The TYPE_CODE has 6 different values.
How do I setup an SSRS matrix to provide the following layout and data:
So far I have a matrix setup (see the pic below) that has a row group (TYPE_CODE1) for the TYPE_CODE data, and two column groups (YEAR_PREV and YEAR_CURRENT) that are filtered as follows:
- The second column in the matrix is the YEAR_PREV group, and is filtered to not show 2019 data (YEAR <> 2019)
- The 4th column in the matrix is the YEAR_CURRENT group, and is filtered to only show 2019 data (YEAR = 2019)
This method correctly splits my data, with the green highlighted columns in the pic below representing what is correct:
What is not correct is the average column, as I cannot figure out how to setup that column to only average the columns to the left (the previous years - 2015-2018) and not include the column to the right (2019).
I have tried several different expressions to no avail, primarily trying to limit the count function to only the YEAR_PREV group, like so:
=count(Fields!TYPE_CODE.Value, "PREV_YEAR")/4
This throws an error telling me that something along the lines of "group cannot be used in aggregate function...".
How do I calculate the average column correctly?
You need to have 2 column groups with filters applied, first one where year equals 2015-2018 and the second one equals only 2019.
In between each of these columns you need insert your average column that will reflect years 2015-2018.

How to fix the error dividing by zero in my expression in visual studio reports?

I created report in visual studio.The problem is with dividing by zero in total fields.
I have one column with value 00:03:15 and another column with 00:00:00
I want to sum these columns and want to show me average value from first and second column.
I used this expression ( formula ) in my case :
=Format(
TimeSerial(0,0,
Round(iif(sum(Fields!N_INBOUND.Value)=0,0,
sum(Fields!T_INBOUND.Value/Fields!N_INBOUND.Value))
+
iif(sum(Fields!N_INBOUND.Value)=0,0,
sum(Fields!T_HOLD.Value/Fields!N_INBOUND.Value)
+iif(first(Fields!HANDLING_TIME_MEASURE_TYPE.Value)=2,
sum(Fields!N_INBOUND.Value-Fields!N_TRANSFERS_TAKEN.Value),0))
+iif(sum(Fields!N_INBOUND.Value)=0,0,
sum(Fields!T_CONSULT.Value/Fields!N_INBOUND.Value)
+iif(first(Fields!HANDLING_TIME_MEASURE_TYPE.Value)=2,
sum(Fields!N_CONSULT.Value-Fields!N_TRANSFERS_TAKEN.Value),0)))/count(Fields!PRESENTATION_NAME.Value))
, "HH:mm:ss")
I used this https://sqldusty.com/2011/08/01/ssrs-expression-iif-statement-divide-by-zero-error/ and looks like :
=Format(
TimeSerial(0,0,
Round(
iif(count(Fields!PRESENTATION_NAME.Value)=0,0,
(iif(sum(Fields!N_INBOUND.Value)=0,0,
sum(Fields!T_INBOUND.Value/Fields!N_INBOUND.Value))
+
iif(sum(Fields!N_INBOUND.Value)=0,0,
sum(Fields!T_HOLD.Value/Fields!N_INBOUND.Value)
+iif(first(Fields!HANDLING_TIME_MEASURE_TYPE.Value)=2,
sum(Fields!N_INBOUND.Value-Fields!N_TRANSFERS_TAKEN.Value),0))
+iif(sum(Fields!N_INBOUND.Value)=0,0,
sum(Fields!T_CONSULT.Value/Fields!N_INBOUND.Value)
+iif(first(Fields!HANDLING_TIME_MEASURE_TYPE.Value)=2,
sum(Fields!N_CONSULT.Value-Fields!N_TRANSFERS_TAKEN.Value),0)))/iif(count(Fields!PRESENTATION_NAME.Value)=0,1,count(Fields!PRESENTATION_NAME.Value)) ) ) )
, "HH:mm:ss")
But shows me an ERROR.Anyone who know how to fix that?
Your data is something like below, Correct me if I am wrong. At the Bottom I have added Total for both columns.
Note: You will have to take care of what type your column (T_INBOUND and N_INBOUND) return values.
Now to create a Total for T_INBOUND and N_INBOUND
To add totals for a column group In the tablix data region row group
area, right-click a cell in the column group area for which you want
totals, then point to Add Total, and click Before or After.
A new column outside the current group is added to the data region,
and then a default total is added for each numeric field in the
column.
Link:
https://learn.microsoft.com/en-us/sql/reporting-services/report-design/add-a-total-to-a-group-or-tablix-data-region-report-builder-and-ssrs?view=sql-server-2017
Once you have Total you can create create a Cell Either next to your Total or below Total and add expression as below
IIF(IsNothing(Fields!Total_N_BOUND.Value) OR Fields!Total_N_BOUND.Value=0,0,
Fields!Total_T_BOUND.Value/Fields!Total_N_BOUND.Value)

SSRS - Sum Last 12 items

I have a Total column and am summing all the values in the row with:
=Sum(Fields!MyField.Value)
How can I sum only the last 12 items?
This is valid:
=Last(Fields!MyField.Value)
I need something like the below...
=Sum( LastX(Fields!MyField.Value, 12) )
You could achieve this result by creating a subquery in your main dataset query. You will just have to have a value that you want to sort on in descending order.
Say you have a table sorted by the price in ASC order. You want to sum the last 12. You just need to flip the sort in the subquery and sum the top 12.
SELECT OtherFields, (SELECT TOP 12 Sum(S1.MyField) FROM MyTable S1 ORDER BY S1.MyField DESC) AS BottomTwelveSum
FROM MyMainQueryTable
Yes this value will repeat in your dataset, however if you place it correctly in the Table you should be fine, just dont show the value in the details section. This wont add additional rows. Another solution would be using a subreport, however this is much quicker on render time.

SUM of a SUM in SSRS 2008

I've this report
Here I make the first sum because I've grouped values from each month (months are "Gennaio", "Febbraio", "Marzo" etc etc.). These values are hidden, but anyway I get the sum and I display the sum for each month.
Then I should make the second sum that use values for each month and display the total for each category. Categories are "TOTALE LAVORI RESTAURO", "TOTALE LAVORI EDILE" etc.)
This is the final sum, where I sum values from each category.
Everything is working well, but now I have to add a "month" parameter to the report that returns sums until a selected month. This parameter changes the sum 1 with this expression:
=Sum(IIf(Fields!mese.Value <= Parameters!mese.Value, Fields!costi.Value, 0))
Now, how should I change expression in SUM2 and SUM3 to work with this parameter?
If I copy that code, ther returns #Error and as far as I know I can't use ReportItems sum.
So any suggestion?
SUM #1 could remain Sum(Fields!costi.Value) because you need to display every months.
i.e.: display GIUGNO even if Parameters!mese.Value = 4 (APRILE).
So you have only to change SUM #2 and #3 because TOTALE LAVORI RESTAURO and TOTALI must show only costi from GENNAIO to Parameters!mese.Value; i.e. if Parameters!mese.Value = 4 display only GENNAIO-APRILE even if we have details about GIUGNO.
The expression gave error because you have NULL value in Fields!costi.Value or Fields!mese.Value: convert this value to zero in your DataSet and you won't have problems.

SSRS Line Chart X-Axis group by Month

everyone. For the life of me I cannot figure out why the X-Axis is pulling 2 dates in each month when I want it to group by each month. In the Values I have:
Value Field =RunningValue(Fields!new_actualsalesfromsplit.Value, Sum, "Chart1_SeriesGroup")
Category Field: =Fields!closedate.Value
Category Groups =Month(Fields!closedate.Value)
Group On =Month(Fields!closedate.Value)
Series Group by ["salesperson']
The chart should have a line for each sales person, and each month should be a cumulative representation of the sales by that person. Thanks for any help.
Set the category field to "=Month(Fields!closedate.Value)", or something similar that will net the results you need. Right now, even though you're grouping by month, you're still telling SSRS to use the atomic data for your X axis, so that's what it's doing.
It may make your task simpler to just add a Calculated Field to your dataset - open the dataset properties window, go to the fields tab, and click "add". Set that field to your month value, use it for grouping and your X axis.