Report Designer query
Hi,
First of all, I am totally new to SSRS.I need to show Top 10 records(sorted - based on some column) in the excel format .After the top 10 - there is a record which shows total for some other column.And after this total record I need to show the
remaining records and just below the remaining records will be a record showing some total fileds which will do the total on some column(s) for the remaining rows above(excluding the TOP 10 records).What is the best approach for this as far as rdl design
is concerned?
Thanks and Regards,
Sandip
November 12th, 2012 7:31am
Please post sample data (CREATE TABLE..+INSERT INTO....)+ desired result.Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Blog:
Large scale of database and data cleansing
MS SQL Consultants:
Improves MS SQL Database Performance
Free Windows Admin Tool Kit Click here and download it now
November 12th, 2012 7:54am
Hi Sandip,
Based on you description, it is hard to work out a solution without the sample data.
Could you please post both the report and the dataset with sample data to us by the following E-mail address? It is benefit for us to do further analysis.
E-mail: sqltnsp@microsoft.com
Regards,
Fanny LiuFanny Liu
TechNet Community Support
November 14th, 2012 1:14am
Hi Fanny Liu,
I have sent u the sample excel format required to
sqltnsp@microsoft.com.Please check your mail.
Thanks and Regards,
Sandip
Free Windows Admin Tool Kit Click here and download it now
November 17th, 2012 1:09am
Hi Sandip,
It seems that there is no built-in function to get the calculation you want. In order to meet your requirement, please refer to the following custom code and design structure.
Dim public totalAmount as Integer
Public Function AddAmount(ByVal Amount AS Integer ) AS Integer
totalAmount = totalAmount + Amount
return Amount
End Function
Public Function GetTotal()
return totalAmount
End Function
Note: the row which display the top ten summary is inside the detail group and the visibility of the row
is controled by the following expression:
=IIF(RowNumber(nothing)=10,False,True).
=IIF(RowNumber(nothing)=10,False,True).
The expression for top 10 sum row:
=code.AddAmount(IIF(RowNumber(nothing)=10,Runningvalue(fields!Amonut.Value,sum,nothing),0))
=code.AddAmount(IIF(RowNumber(nothing)=10,Runningvalue(fields!Amonut.Value,sum,nothing),0))
The expression for remaining sum row:
=Sum(Fields!Amonut.Value)-code.GetTotal()
=Sum(Fields!Amonut.Value)-code.GetTotal()
For more information, please see:
Using Custom Code References in Expressions
RunningValue function
Regards,
Fanny Liu Fanny Liu
TechNet Community Support
November 19th, 2012 3:12am
Hi Fanny,
The solution provided by you is really kool but facing one issue.What if I need to hide the "total 10 sum" row and show the "remaining sum" only - in this case its showing #Error.Please
provide some solution.
Thanks and Regards,
Sandip
Free Windows Admin Tool Kit Click here and download it now
November 19th, 2012 9:27am
Hi Sandip,
If you just want to display the remaining sum row, we can get the exact result simply with the built-in function. Please refer to the following expression:
=RunningValue(IIF(Fields!RowNum.Value<=10,0,Fields!Amonut.Value),SUM,nothing)
In that case, the report should contain a filed which displays the row number, please refer to the following query to add the field.
SELECT Amonut, ROW_NUMBER() OVER (ORDER BY table_column) as RowNum,
FROM
table
For more information, please see:
ROW_NUMBER (Transact-SQL)
Regards,
Fanny LiuFanny Liu
TechNet Community Support
November 20th, 2012 1:37am