SSRS Reporting Services Horizontal Running Total - reporting-services

I have a weekly sales report across several locations. I need to include the week's total and the running total for each.
Location | Week1 | Week2 | Week 3 | Total
____________________________________________________________
Boston | $45000 | $48000 | $54000 | $147000
------------------------------------------------------------
Boston RTotal | $45000 | $93000 | $147000 |
------------------------------------------------------------
New York | $78000 | $84000 | $92000 |
------------------------------------------------------------
New York RTotal | $78000 | $162000 | $254000 | $254000

I think you can achieve that by using RUNNINGVALUE function and playing around with matrix grouping settings.
First create a matrix with these groups:
Now in the highlighted cell use the following expression:
=RunningValue(Sum(Fields!Sales.Value),Sum,"Location")
Note Location is a group in my matrix.
RunningValue will evaluate the Sum(Fields!Sales.Value) expression and sum the values in the given scope. When you preview the report it will produce the following matrix:
Hopefully this is what you require, let me know if it helps.

Related

SSRS report - pivoting data (last columns grouping)

I am trying to achieve the attached prototype for ssrs report. I was able to get all the data but can not figure out how to show the last three columns ("First Time Posted", "Last Time Cancelled" and "Total Duration")
When i try with expression it show data for every single corresponding line, just want to show one entry based on group.
Thank you,
Desired output
Report design
Data will be like
| Cp Label | Time Posted | Time Cancelled| Duration | Link ID|
---------------------------------------------------------------------
| Cp 1 | 12:56:00 | 12:57:05 | 00:01:05 | 1 |
---------------------------------------------------------------------
| Cp 2 | 12:57:05 | 1:00:00 | 00:02:55 | 1 |
---------------------------------------------------------------------
| Cp 3 | 12:57:00 | 1:15:00 | 00:18:00 | 2 |
---------------------------------------------------------------------

SSRS aggregate data for days and for month within the same table

Supposing the following dataset:
- product
- date
- producedUnit
How can I realize the following tale:
Product | sum of Produced Unit this day | sum of produced Unit this Month
I don't want group record so if in the dataset there are 10 product I want to display them all.
As example:
Input dataset:
+--------+-------------+---------------+
|Product | date | produced unit |
+--------+-------------+---------------+
| M&Ms | 2018-02-08 | 5 |
+--------+-------------+---------------+
| M&Ms | 2018-02-08 | 2 |
+--------+-------------+---------------+
| M&Ms | 2018-02-28 | 3 |
+--------+-------------+---------------+
| Kit Kat| 2018-02-08 | 10 |
+--------+-------------+---------------+
| Kit Kat| 2018-02-28 | 10 |
+--------+-------------+---------------+
Today is 2018-02-08
Output:
+--------+-------------------------------+---------------------------------+
|Product | sum of Produced Unit this day | sum of produced Unit this Month |
+--------+-------------------------------+---------------------------------+
| M&Ms | 7 | 10 |
+--------+-------------------------------+---------------------------------+
| M&Ms | 7 | 10 |
+--------+-------------------------------+---------------------------------+
| M&Ms | 7 | 10 |
+--------+-------------------------------+---------------------------------+
|Kit Kat | 10 | 20 |
+--------+-------------------------------+---------------------------------+
|Kit Kat | 10 | 20 |
+--------+-------------------------------+---------------------------------+
Add a calculated field to your Dataset that gets the Month of the production date. For this example, I used =Month(Fields!Date.Value), but if you are crossing years, you may need to use the first day of each month as your common value.
Add a calculated field to get the number produced today. For example:
=IIf(Fields!Date.Value = "2/8/2018", Fields!Produced.Value, Nothing)
Create a new Table. Change the "Details" group to be grouped by Month. Add a parent row group that is grouped by Product.
The expression for "sum of Produced Unit this day" would be like this:
=Sum(Fields!Produced_Today.Value)
The expression for "sum of produced Unit this Month" would be like this:
=Sum(Fields!Produced.Value)
Here's a sample of the result:
Explanation: The table first groups by Product and then by month. You could hide the month and date columns if you don't want to show those. The amount produced today is being filtered at the Dataset level. The amount produced this month is being summed within the scope of the Month group.
Obviously, this is a trivial example, but you can take the principles shown here to account for more variables such as multiple months in your dataset.

Need to Aggregate on the Last Month for a Grouped Report

I have a dataset that looks like the following:
| Location | Category |Item Name | Month | QTY |
| -------- | -------- | -------- | -------- | --- |
| NY | Hardware | Screw | Jan 2017 | 100 |
| NY | Hardware | Screw | Feb 2017 | 50 |
| NY | Hardware | Screw | Mar 2017 | 75 |
| NY | Hardware | Bolt | Jan 2017 | 30 |
| NY | Hardware | Bolt | Feb 2017 | 90 |
| NY | Hardware | Bolt | Mar 2017 | 50 |
| CA | Hardware | Screw | Jan 2017 | 100 |
| CA | Hardware | Screw | Feb 2017 | 50 |
| CA | Hardware | Screw | Mar 2017 | 75 |
| CA | Hardware | Bolt | Jan 2017 | 30 |
| CA | Hardware | Bolt | Feb 2017 | 90 |
| CA | Hardware | Bolt | Mar 2017 | 50 |
My report needs to look like the following:
| Hardware | Screw | Bolt |
|Current Month Total | 150 | 100 |
|Yearly Total | 450 | 340 |
I need a way to limit the current month total to ONLY the current month but aggregate the values for the yearly total. I've tried using LAST in the aggregate but you can't. I've tried the following for the current month total aggregate. My Date value is the 1st day of the month and my parameter is the last day of the month, so I needed a way to match the 2 that is why there is the date addition. The jist is to try and match the current month, which is a parameter to the date column:
=iif( DateAdd(dateinterval.Day,-1,DateAdd(dateinterval.Month,1,Fields!Sale_DATE.Value)) = Parameters!ReportingDate.Value, iif(isnothing(sum(Fields!Total.Value)),"",sum(Fields!Total.Value)),sum(0))
but it only works if the query that returns the dataset returns ONLY the current month. If the query returns all of the months in the year it shows 0's. I need a way to filter the cells so they aggregate the values correctly
If I limit my report to only the current month I can't get the yearly aggregate and if I select all of the months I can't get the current month total.
You can do this using the built-in grouping functions without any fancy expressions.
Add a row group by month. Filter the row group to the current month. Add a column group by Item Name. Add a row outside and below the row group to get your yearly totals. The expressions will all simply be a sum of the Qty. The report will take care of summing the values within each group scope.
Actually, using grouping as suggested alone doesn't work. I was already using groups in my matrix. The issue is that I needed a different form of grouping within the same column and I needed to restrict the grouping to different date ranges. My problem was that I had the SUM in the wrong position in my formula.
The expressions for the yearly total should have been:
=Sum(IIF(Fields!ItemName.Value="Screw",Fields!QTY.Value,0))
=Sum(IIF(Fields!ItemName.Value="Bolt",Fields!QTY.Value,0))
Then, based on the dataset, if the current month is "Mar 2017" I can build the expression for Month Total as
=Sum(IIF(Fields!ItemName.Value="Screw" and Fields!Month.Value="Mar 2017",Fields!QTY.Value,0))``
=Sum(IIF(Fields!ItemName.Value="Bolt" and Fields!Month.Value="Mar 2017",Fields!QTY.Value,0))
These examples are using my sample dataset in this question. Since I couldn't hard code dates, wanted to use parameters, and needed to do a calculation this is what I ACTUALLY used:
SUM(iif(DateAdd(dateinterval.Day,-1,DateAdd(dateinterval.Month,1,Fields!REL_DATE.Value))= Parameters!ReportingDate.Value,
Fields!Total_OnTime.Value,0))/SUM(iif(DateAdd(dateinterval.Day,-1,DateAdd(dateinterval.Month,1,Fields!REL_DATE.Value))= Parameters!ReportingDate.Value,
Fields!Total.Value,0))
Hope this helps someone else.

SSRS Dynamic Running Total

I am trying to include a cumulative total column in a matrix on a report.
This is the expression I am using at the moment:
=RunningValue(Ceiling((SUM(Fields!MINUTES.Value)/60)*4)/4,Sum,"RowGroup")
The problem is the total seems to reset on each day.
I have 3 groups on the report: Parent is Day of month, type, then sub type.
I want it so that the sub types will accumulate across the days:
So 1st june/holiday/annual = 2 - cumulative = 2
.. 2nd june/holiday/annual = 1 - cumulative = 3
rowgroup in the expression above is the 3rd level sub type group in the matrix.
Whatever I try I cannot get it to total up over the days, like i said above it seems to not carry over to the next day.
Below is a sample dataset:
+------+------------+---------+----------+---------+
| User | Date | Type | Subtype | Minutes |
+------+------------+---------+----------+---------+
| 158 | 13/02/2015 | Holiday | Annual | 90 |
| 158 | 13/02/2015 | Meeting | Training | 300 |
| 158 | 13/02/2015 | Lunch | Lunch | 60 |
| 158 | 03/06/2015 | Holiday | Annual | 120 |
| 158 | 03/06/2015 | Meeting | Meeting | 285 |
| 158 | 04/06/2015 | Holiday | Sick | 120 |
| 158 | 04/06/2015 | Holiday | Annual | 200 |
+------+------------+---------+----------+---------+
My matrix column group is the user.
The row groups are date, then type, then subtype.
I then have a total column outside the column grouping.
I'm now trying to add in to the report a cumulative total based on the type and sub-type columns, that sums up the minutes.
As an example (looking at the holiday, annual entries):
03/06/2015 - 120 minutes
13/02/2015 - 90 minutes = 210 minutes
04/06/2015 - 200 minutes = 410 minutes.
Taken from the MSDN page for RunningValue, adding a scope to your expression will have this effect.
The value for RunningValue resets to 0 for each new instance of the scope. If a group is specified, the running value is reset when the group expression changes. If a data region is specified, the running value is reset for each new instance of the data region. If a dataset is specified, the running value is not reset throughout the entire dataset.
To fix the issue, simply remove the scope:
=RunningValue(Ceiling((SUM(Fields!MINUTES.Value)/60)*4)/4,Sum)
This will have the total run across all days (As days are your top-most level). If this is incorrect could you perhaps give us an example of what the report is currently doing, and what you want it to do?

Chart reporting in SSRS

I am using SQL Server Reporting to display data using a chart. How do I create my dataset so that the graph displays one line for males & one line for females.
Thanks
Beth
Do you mean two lines as in
one per x or y axis
one per data series
This stupid thing won't allow me to comment so I'm wasting space with an answer
I think what you want is to separate the males and females into different data series. You can go this in the chart properties, as long as you have enough information in your data set.
If your data set looks something like this:
+-----------+-----+-------+
| Date | Sex | Count |
+-----------+-----+-------+
| 2009-01-1 | M | 124 |
+-----------+-----+-------+
| 2009-01-1 | F | 78 |
+-----------+-----+-------+
| 2009-01-2 | M | 95 |
+-----------+-----+-------+
| 2009-01-2 | F | 101 |
+-----------+-----+-------+
Then if you have the Date as the X-Axis variable, Count as the Y-Axis, and add the Sex as the Series Grouping, the it should automatically split them into two graph lines, and add a Legend etc.