Reporting services get total sum - reporting-services

I want to get the total sum of a particular column in a report. I have tried using =Sum(Fields!baseline_number.Value) but this gets the sum for each row and when I use
=RunningValue(Fields!Quantity.Value, Sum, Nothing)
I get the cumulative sum. I wouldn't mind using =RunningValue(Fields!Quantity.Value, Sum, Nothing) then getting the final value because this would be the sum for all the rows. Is there a simpler way to achieve getting the total for a certain row in a report?

Related

Calculate total sum for the grouping of child group using Aggregate sum or group by sum Expression

I am trying to calculate a sum based on Category of business
(Total sum of Type 1, Total sum of Type 2 and 3).
I created calculated fields for all 3 which is given below :
''=SUM(If(Fields!Category_of_business.Value="Type1",Fields!Selling.Value,0))''
For which I am getting an error that Aggregate functions are not allowed in calculated fields. Is there any workaround? Visual rep of SSRS table

Is it possible to limit RunningValue to look back for a certain number of rows?

Im trying to average the past 5 rows in my table i created in SSRS grouped by date(Monday of every week). Ive tried runningValue however it looks back at all the past rows for each group. Is there a way to limit the scope to just the past 5 rows or weeks for each Date group.
Thanks
I would accomplish this with grouping. I don't know what your dataset is like but I assume it is a SQL query you can modify. The easiest solution would be to add a week number column to your query. For example:
SELECT datepart(week, YOURDATE) as WeekNumber
More info on datepart:
https://learn.microsoft.com/en-us/sql/t-sql/functions/datepart-transact-sql?view=sql-server-2017
Once you have a week number, use the table creation wizard in Report Builder and add WeekNumber as a row group. This will group your values by week number and give you a total under each week. You can change the total by double clicking and making it AVG() instead of SUM().
Note: If you already have each 5 day period in a group, you should be able to right click that and add total. At which point you can just change the SUM to AVG there.

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.

Calculate average for the those who meet a certain criteria

I'm trying to calculate the average for only particular records
For example, we have a field called FurthestSlide. This field will contain numbers. We have another field called SlideCount. This is also a number field.
I only want it to calculate the average for the records where the FurthestSlide does not equal the SlideCount number.
What I am trying to find is the average FurthestSlide number for those people who did not view the entire message.
I do not want those who finished the message to be calculated in the data.
Sample Data:
SlideCount=40
FurthestSlide=(30,20,40,40,40)
The answer should come out to 25. (30+20)/2
You can exclude certain rows from an aggregate.
With your data:
And a simple report:
I have calculated the average for non-matching rows with the expression:
=Avg(IIf(Fields!FurthestSlide.Value <> Fields!SlideCount.Value
, Fields!FurthestSlide.Value
, Nothing))
Here we set matched rows FurthestSlide value as Nothing, which means they are excluded from any average calculation.
This gives the required result for your data:

sum of last field

I have a trouble to sum fields.
This is what I have: I have list of employees and two rows of values for each, I also have calculations in SQL of running total for the 8 and 16 weeks for each employee for each of two rows using windowing function. I have to group employees by branches they work and calculate sum of running totals for the last 8 and 16 weeks for each row and then device row 1 by row 2. I need to use Last function, because I only need the running total for the last 8 and 16 weeks. The challenge is to go around and have something like: Sum(Last(Fields!Last116WeekSilk.Value) . this one obviously gives me an error. I have tried to add calculated field to the dataset with both Sum and Last functions, doesn’t work, tried RunningValue, doesn’t work. What else can I do to have the sum of last running totals?
Many thanks in advance
I would add the SQL ROW_NUMBER function to the query and derive the row number (e.g. 1 or 2) within each group. If you do this in descending sequence the row number 1 will always be the last row within the group.
Then in SSRS you can use an Iif to only show/calculate on row number 1.