Need to Display records Group By in SSRS - sql

In SSRS 2008, I am developing the report that should display the records based on condition: It should give me the amt_total based on gift_type (Here, amt_total and gift_type are columns of the table).
This is the query I am using.
SELECT o110113.gift_batch_no,
o110113.gift_type,
(o110113.gift_date),
o110113.feed_doc_code,
SUM (o110113.amt_total)
FROM GIFT_CARD o110113
WHERE (o110113.gift_type IN
('RR', 'RB', 'CR', 'RM', 'RW', 'CW', 'RJ', 'RO', 'RK', 'CI')
)
GROUP BY o110113.gift_batch_no,
o110113.gift_type,
(o110113.gift_date),
o110113.feed_doc_code
ORDER BY o110113.gift_batch_no ASC, o110113.gift_type ASC
And the report I am trying to generate in SSRS 2008 should look like this.
Clikck this to see the Image of the Report that I am trying to develop
I am trying to use the SSRS expression
=Sum(Fields!SUM_O110113_AMT_TOTAL_.Value,"GIFT_TYPE")
It is throwing me the error saying:
Please click this to see an Error I am getting in SSRS
Kindly provide the Solution
This the report design I have developed
[click to see the Image of report]
Thanks
Arun

Here you need to do group by of your Tablix.
First you need to add Row group on gift_batch_no so that will dispaly based on gift batches.
Another row group your have to create on Gift type and in that second group type you need to set SUM of total amount it will work.
Let me know if you have any other query

That error has to do with the scope of your sum. without seeing the data sets and assuming it is not a nested aggregate operation based on the image. you are trying to reference the column name "GIFT_TYPE" when it should actually be the name of the record set, or the appropriate scope(data region/group).
here is how scope works from the provided link below
The value of scope must be a string constant andcannot be an
expression. For outer aggregates or aggregates that do not specify
other aggregates, scope must refer to the current scope or a
containing scope. For aggregates of aggregates, nested aggregates can
specify a child scope.
you will want to see this link for more information

Related

SSRS: Repeat Down Total from Matrix in all rows

Need some help in SSRS,
New to this so apologies ahead if not entirely up to scratch with answers.
I am trying to get the Total of a column and repeat the value of that total (Total Checks - see image) across all the rows.
Below is image:
I have tried multiple different ways, each time with failure.
Any help would be much appreciated.
Thanks,
Depending on where you are getting your data from, you have different options. For example, within SQL you could use windowed functions:
select Date
,Checker
,sum(Checker) over () as TotalChecks
,sum(Checker) over (partition by Date) as TotalChecksByDate
from table
or within SSRS expressions by explicitly stating your scope, either for the dataset as a whole:
=sum(Fields!Checker.Value, "YourDataset")
or just for the grouping within your table:
=sum(Fields!Checker.Value, "YourTableGroupName")

Summing up an average column in ssrs

I need some help with trying to Totaling a column that is taking an average.
The column has an expression of: =avg(Fields!UOS_2017.Value)
I want to sum this column so I would think I could simply do: =sum(avg(Fields!UOS_2017.Value))
BUT this does not work. The total should be 3,606.
Here are my results
Here is my Design view
Update I am attached a sample of the data that is being used to create the report. Sample Data
Will anyone help me with the expression I should be using or help with a custom code. I appreciate any help.
Thank you in advance.
I'm assuming you have three row groups called something like
VP Rollup, Director Rollup and Cost Center
In this case you need to change your expression to be something like
=Sum(Avg(Fields!UOS_2017.Value, "Cost Center"))
This basically says "take the average at the cost center scope and then sum the results at the current scope (which would be at Director Rollup level).

How to add a figure to only a particular group in vb.net RDLC report

I have an RDLC report which sums totals for each group in VB.Net. It is working fine but what I want to do is to add a figure outside the group to only a particular group based on users selection.
Assuming there are three groups: Food Dept, Security Dept and Sales Dept. I want a figure 2000 to be added to only the Food Dept without affecting the Sales and Security Dept. Any help?
You can use an expression like this:
=Sum(Fields!ValueToSum.Value) + IIf(Fields!Departments.Value = "Food Dept", 2000, 0)
This is a simple example: use ReportParameters instead of constant ("Food Dept", 2000).
I would add a parameter and assign the value. An integer parameter for ex: #FoodDeptOffset can be added to the fields as
=Sum(Fields!FoodDept.Value) + (Parameters!FoodDeptOffset.Value)
Thanks A lot for the answers. I was able to sort it out by passing a parameter which did the trick. On the main form which loads the Reportviewer I attached A combo box giving the users an option to select which field the wanted to add to and the passed it as a parameter to the rdlc report.

How to group records where a subset matches a condition

I have created a Microsoft report in VS2008 that displays details of products that are tested in a factory. Relevant fields to this problem are: SerialNumber (int), Pass (bool).
There is also a record ID which means several entries may exist per SerialNumber.
What we would like the report to show is to be grouped where SerialNumbers have never met the condition Pass=True (i.e. actual rejects) and the rest under where at least one record shows Pass=True.
The expression for the grouping currently is "=Fields!Pass.Value" which splits pass and fail records (and are then sorted etc).
In case anyone else comes up against this and wants to know how I solved it, I added an extra boolean column to the SQL query called 'Reject' which returns true or false and used this to group the report.
As powerful as the reporting can be, it just appears to be quite limited on what it can do with set data beyond Count, CountDistinct etc.

Get the Attributes filter by using its display name?

I am trying to desgin a MDX query with Date filter which is an hierarchy attribute.. Now, I need to place the attribute filter value in the "where" clause.. When I drag and drop the attribute say - '2012', it gets converted to someother format like '[Date].[Fiscal Hierarchy].[Year].&[2.012E9]' whereas in leftpane display it shows as 'YR 2012'..
How do I control this conversion ? I am not sure on what basis it converts this attribute like that ?..
I need to build the MDX query dynamically in program based on the user selection.. How do I determine it is '2.012E9' when the user selectes '2012'? Or is there any way to alter the filter condition in MDX so that I can acheive this without using [2.012E9] string ?
Thanks in advance..
SELECT
[Subjects].[Name] on Rows,
[Student].Name ON COLUMNS
FROM Cube
where
[Date].[Fiscal Hierarchy].[Season].&[**2.0121E9**]
-- But the left side pane(Cube browser) shows the attribute as 'YEAR 2012'
Each member has a unique name and a display name.
In the left pane you see the display name. In the Mdx query the key of the member is used (see MSDN).
If you want to change the unique names you have to change your keys.
I am able to do this by changing the query like this:
SELECT
[Subjects].[Name] on Rows,
[Student].Name ON COLUMNS
FROM Cube
where
[Date].[Fiscal Hierarchy].[Season].[YEAR 2012]