Show/hide groups of rows without subtotalling in SSRS 2005? - asp.net

I have a matrix report in SSRS 2005, and the rows have certain sections. Imagine along the left a series of
1 $100
2 $400
3 $150
4 $650
5 $500
6 $400
7 $900
And I want some rows to be able to be hidden. For example, row 7 are totals of row 5 and 6, so I'd want to +/- next to row 7 that will show/hide rows 5 and 6. (Note that I don't calculate these totals, they were done by an accountant and it is important that I use the values in the database and don't calculate the totals myself.)
Now I have this "parent/child" relationship in the database, and I could add that as a group on the row
4 1 $100
4 2 $400
4 3 $150
- 4 4 $650
7 5 $500
7 6 $400
- 7 7 $900
And then I could add the toggle to that first column, BUT I don't want the values to be subtotaled when they are rolled up. I simply want rows 5/6 to disappear and only show row 7. Kind of new to SSRS so any suggestions would be great.
So with one group toggled:
+ 4 4 $650
7 5 $500
7 6 $400
- 7 7 $900
Other gorup toggled:
+ 4 4 $650
+ 7 7 $900
Etc.
4 1 $100
4 2 $400
4 3 $150
- 4 4 $650
+ 7 7 $900
How can I accomplish this such that I am not recalculating the parent rows(rows 4 and 7 in this example)?
If there is a free web control that can accomplish this in ASP.NET I'd be glad to hear about it as well. I have a sinking feeling that I'm going to have to write some AJAX myself to accomplish this. I kind of wondered if there was some hack to embed some javascript into the report that could accomplish this.

Effectively you have two problems:
Report subtotals that come from the database, not calculated
Dynamically hide and expose detail rows
You can do this with a standard table report, as follows:
Report database subtotals
You can do this in plain SQL (D is the Detail table and G is the Group table):
SELECT D.ParentId, D.ChildId,
D.Description as DetailDescription, D.Amount AS DetailAmount,
G.GroupDescription, G.GroupAmount
FROM MyTable D INNER JOIN
(SELECT ChildId AS GroupId, Max(Description) as GroupDescription, MAX(Amount) AS GroupAmount
FROM MyTable
GROUP BY ChildId
WHERE ChildId IN (SELECT DISTINCT ParentId FROM MyTable)) G ON GroupId = D.ParentId
WHERE D.ChildId NOT IN (SELECT DISTINCT ParentId FROM MyTable)
So what we are doing is getting all the rows which aren't subtotals (that is, the rows where the ChildId is not a ParentId) and in the nested select we are also putting the subtotal on every detail line. Now, in the Group on the table, we can simply report the GroupTotal field from our dataset rather than an actual subtotal.
Dynamically hide and expose rows
Create a group in your table. Here is where you report the GroupTotal just as a field, not as a total (although you could MAX or MIN it if you wanted to).
Right-click the detail group and click Edit. On the Visibility tab, check the Visibility can be toggled by another report item checkbox and select the textbox name of the first textbox of the group above. Set the Initial Visibility to either Visible or Hidden as required.
Off the top of my head and untested but you should get the idea.
Edit to explain layout better (Note: SQL above also edited to show descriptions)
I'm working with a table here, not a matrix.
Layout would look like as follows (first column shows what group you are on):
Table Header Parent Id Child Id Description Amount
Group1 Header =Fields!ParentId.Value =Last(Fields!GroupDescription.Value) =Max(Fields!GroupAmount.Value)
Details Group =Fields!ParentId.Value =Fields!ChildId.Value =Fields!DetailDescription.Value =Fields!DetailAmount.Value
Group1 is set to Group on ParentId, only the header is displayed (no footer) and the ParentId Textbox on that group is called ParentIdGroup. Details Group has "Visibility can be toggled by another item" checked and "Report item" is set to ParentIdGroup.
I have mocked up this report now and it works as you describe - what looks like subtotals are actually database fields and the description shows on the group row.

I was able to accomplish this by setting the expression for the data field value to Last, since in my case the subtotals are always the last row of the series of rows. Whenever the rows are expanded, then Last displays the value for each row, since each row is it's own group. And then whenever I collapse using the PatenLineNumber toggle, then the Last shows the value of that parent row, since it appears as the last row in the group.
So my matrix report is something like this:
Amount
ParentLineNumber ChildLineNumber =Last(Fields!Amount.Value)
I am still having a seperate issue, but that is a seperate question.

Related

DevExpress PivotGrid Cell Editing in C# WinFForms

We use the PivotGrid component for data editing in our application. When the user changes the value of a column, through the EditValueChanged event we change all the data in this column with the CreateDrillDownDataSource resource. But we need to change all data of all columns at the same level as the changed column. Is there any way to do this?
We use 13 columns. 12 are for the monthly amounts and column 13 is for the total. From column 13 we distribute the total value by the records of column 13. Then in a loop from 1 to 12 we do it for the other columns. But the differences are very high.

How to Show Null in a Cell in MS Access 2010

Alright, so I'm trying to run a query that to display a null value in a field if a duplicate ID exist. There are 2 tables, parent-child relationship. The parent table can have one to many child records. In my scenario, we have fuel tanks that can get many inspections done on them. Tank is the parent table and Tank_Inspections is the child table. There's a capacity data field that I'm getting from the tank table and joining it with the tank inspection record and it shows up twice if multiple inspections exist for that tank. This is fine, however I don't want to double count the capacity and only want to show it once. I've pasted the link to an image of a screenshot of how it should be displayed if multiple records exist for parent table. The highlighted cell should be blank. As you can see, the TankID = 65 has two inspections of different types, since I'm getting the capacity field from the Tank table, it's getting inserted twice. I was to write a query so if two or more inspections exist for tanks, only show the capacity once and "blank" out the other capacity data element. In this case, the highlight cell should be blank. Suggestions?
http://imgur.com/6bYE8wS
This sounds like a job for an analytic function. Since Access doesn't natively support these, there is a hack to accomplish the row_number() analytic function that sounds like it would meet your needs:
Achieving ROW_NUMBER / PARTITION BY in MS Access
You create a query that invokes this self-join and use that instead of the table. Once you have the row number on each row, it would look something like this:
Tank ID Inspection ID Row
59 6841 1
60 6842 1
65 7344 1
65 6843 2
And your capacity formula would change from [Inspection].[Capacity] to something like this:
IIf([Self Join].[Row] = 1, [Inspection].[Capacity], Null)

Need help regarding a specific type of report design by ssrs

i want to show one master and one detail data.
master data from sale table and detail data from phone table
there is no relation between two table only one field is common in two table that is country code.
in the first page i want to show data regarding UK like
UK details it is title country wise
-----------------------------------------------------------------------
Total Sale : 112300 Diag sale: 1300 Reman sale : 10000
Caller Name incomming call out going call call transfer
---------------- --------------------- ------------------- ----------------
keith 5 5 2
john 3 2 1
sam 8 4 5
in the next page same data will come but USA data will show. so in this way country specific data will show in each page.
i am new in ssrs so i am not getting any idea how to design this report with ssrs
my store will supply data and it will take only one parameter like country code. if i pass country code like 'GB,US,DE' then my sp will return two result set first result set will fetch data from sale table for country GB,US and DE like
total_sale, diag_sale, Reman_Sale, countrycode
112300 1300 10000 GB
10200 1200 4700 US
4200 1500 5600 DE
first result will look like above output
second result set will look like
callername incommingcall outgoingcall calltransfer countrycode
keith 5 5 5 GB
john 3 2 1 US
sam 8 4 5 DE
so discuss in detail how could i design this type of report with ssrs.
Good Morning,
In addition to anakulk's solution, you could display detail records using a sub report. You would create the master report which contains the data from your sales table. You would create another report that is based on the phone table.
On the master report, you would insert a sub report, select the report you built based on the phone table, and link it using the country code. This way, whenever you have the UK sales information displaying, the sub report will display the details from the phone table that have UK in the country code field.
Do you know about Datasets?
If yes then then in dataset query you can join two tables to get whatever you want on report.
Now on report:-
1)You can take a tablix
2)In that tablix ,on first row you can write expression for displaying CountryName
3)on second row of tablix, you can put "Total Sale : 112300 Diag sale: 1300 Reman sale : 10000 "
4)and finally on 4th row you can put the details fields.
5)You have make a row group ,group by CountryCode.
This just a brief idea..I hope this will help you a bit to atleast start..

Repeater with dynamic number of columns

Repeater with dynamic columns.
I have to show columns based of settings. Sometimes I want to show Name, Age, Sex, Salary. So the stored procedure will return
Name Age Sex Salary
-----------------------
Rauf 23 M 10
Amal 25 M 10
Sometimes I need to show Name and Salary only. So the data will be
Name Salary
------------
Rauf 10
Amal 10
How can I design a Repeater control to show this type of tables having dynamic columns ?
Unless perfomance i really crucial, I would take the easy way and use fixed columns (all of them) and just set visible=false in case you do not need them.

Restricting number of rows in Datalist

In my asp.net I am using Datalist in that I want to limit row count and want the sort to be in vertical. Let me know how to do this.
Ex: I want my list to be like this
1 4
2 5
3 6
for your first issue, restricting to number of rows is, just pass the required data to datalist and for vertical , use this property RepeatDirection="Vertical"

Resources