1. Trang chủ >
  2. Công Nghệ Thông Tin >
  3. Tin học văn phòng >

How do I hide the toggle image (+) if there is no row when using drill-down?

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (5.77 MB, 182 trang )


Part III: Reporting Services



How do I achieve nested aggregation?

Answer

To avoid using Expression with nested aggregations “Sum(Max(Data))”, you can

change the dataset. For example: add a new column in your dataset to calculate

the Max value for the group and then use the Sum(Max(…)) in your report.

Or you can try the workaround below. Imagine that group1 contains group2 and

group2 contains details, and you want to use sum(max(data)):

1. Add a “fake” in dataset like this

UNION

SELECT '_fake' AS Group1, '_fake' AS Group2, '_fake' AS

Detail, … …



2. Sort the data by descending, so the fake data will show at the last group

because of the character ‘_’.

3. Copy the following code to the custom code area:

Dim Aggregation as Decimal

Function AddValue(ByVal NewValue As Decimal) as Decimal

Aggregation = Aggregation + NewValue

Return Aggregation

End Function

Function GetAggregation () as object

GetAggregation = Aggregation

Aggregation = 0 'Reset the group

Return GetAggregation

End Function



4. Delete the footer of group1, then right-click the handle of group1’s header

and insert a row above. Below is the structure:

Group 1 new Header

Group 1 Header

Group 2 Header

details

Group 2 Footer



Microsoft SQL Server TechNet Forum Support Team | Part III

Reporting Services



66



Part III: Reporting Services



handles

1



(Tableheader )

=Previous(Fields!group1.Va



=code.GetAggregation



lue)



()



1



= (Fields!group1.Value)



2



=Fields! Group2.Value



=code.AddValue(max(

data))



==



Details



details



(Table footer)



5. Right-click the handle of the new header, click the properties (not edit

group). In Properties window, set the visibility to be

“=iif(Previous(Fields!group1.Value) is nothing, true,false)”.

6. Right click the handle of each one of the other rows, click the properties (not

edit group). In Properties window, set the visibility to be

“=iif(Fields!group1.Value = "_fake", true,false)”.



Microsoft SQL Server TechNet Forum Support Team | Part III

Reporting Services



67



Part III: Reporting Services



How do I achieve column break in a matrix?

Answer

Here are some workarounds, available forboth Reporting Services 2005 and2008:

Workaround 1

Spread the columns from one matrix into several matrixes. You can first copy one

matrix and then paste it into several ones you want. Then set the filter for each

column group to make sure that the total columns’ length in one matrix just fit a

page’s width.

Workaround 2

The other method is to use a custom code.

1. Please copy the following code to the custom code area:

Dim FlagTable As System.Collections.Hashtable

Dim Flag AS Integer

Function MyFunc(ByVal NewValue As Object) As Integer

If (FlagTable Is Nothing) Then

FlagTable = New System.Collections.Hashtable

End If

If (NewValue Is Nothing) Then

NewValue = "-"

End If

If (Not FlagTable .Contains(NewValue )) Then

Flag =Flag + 1

FlagTable.Add(NewValue, nothing)

End If

MyFunc = Flag

End Function



2. Create a list in your report.

Imagine that the column group of a matrix is grouped bythe field

‘Column_Group’, then set the detail group of list withthe expression like this:

=Ceiling(Code.MyFunc(Fields!Column_Group.Value)/5)

Note: This means the Max number of column in matrix will be five after you

follow step C.

3. Sort the dataset by column group field, and then drag the matrix into the list.

Click Preview.

Workaround 3

Microsoft SQL Server TechNet Forum Support Team | Part III

Reporting Services



68



Part III: Reporting Services



Similar to the second method, you need to modify the dataset.

1. Create an ID column for the column group in your dataset.

For example,there isa datasetwith the following query:

SELECT * FROM Table



The column group is grouped on the field “Group1”.Then, modify the query

like this:

SELECT *, Dense_Rank()OVER(order by Group1) AS ID FROM Table



2. Create a list in your report, set the detail group of the list with the Expression

like this:

=Ceiling(Fields!ID.Value/5)

Note: This meansthat the Max number of column in matrix will be five after

you followthe step C.

3. Sort the dataset bythe column group and then drag the matrix into the list.

Click Preview.



Microsoft SQL Server TechNet Forum Support Team | Part III

Reporting Services



69



Part III: Reporting Services



How do I use Parent-Child Hierarchies and formatted value

in report with Analysis Services?

Answer

To resolve this issue, you can use the Extended Field Properties which is

supported in SSRS.

To retrieve the extended properties, for example Formatted Value, you need to

add the properties to the MDX query:

VALUE,BACK_COLOR,FORE_COLOR ,FORMATTED_VALUE

,FORMAT_STRING,FONT_NAME,FONT_SIZE,FONT_FLAGS



Afterwards, use the extended property in your cube:

=Fields!Employees.FormattedValue

For more information, reference:

http://msdn.microsoft.com/en-us/library/ms156477.aspx

Imagine that Employees is the Parent-Child Hierarchy, so the group expression in

report could be:

=Fields!Employees.UniqueName

Father group expression could be:

=Fields!Employees.ParentUniqueName

Value expression could be:

=Fields!Measure.FormattedValue

Afterwards, set the visibility property, padding property for the report as above

documents described.

Next, you may want to filter the data in your report. For example, just display

memberA and the descendant and ancestor of memberA. Simply creating the

filter in report may not work, because you may destroy the parent-child

relationship. It can be achieved in query designer. Drag the hierarchy to the filter

pane, select the option ‘Parameters’. Or try the query below to display

descendant and itself:

SELECT

NON EMPTY

{[Measures].[Reseller Sales Amount]} ON COLUMNS

,NON EMPTY

{Descendants(StrToSet(@EmployeeEmployees,CONSTRAINED))}

DIMENSION PROPERTIES MEMBER_CAPTION,MEMBER_UNIQUE_NAME

Microsoft SQL Server TechNet Forum Support Team | Part III

Reporting Services



70



Part III: Reporting Services



,PARENT_UNIQUE_NAME ,LEVEL_NUMBER

ON ROWS

FROM [Adventure Works]

CELL PROPERTIES

VALUE,BACK_COLOR,FORE_COLOR ,FORMATTED_VALUE

,FORMAT_STRING,FONT_NAME,FONT_SIZE,FONT_FLAGS;



Note: For relational databases, if you want to filter the members, you need to

create a dataset with Common Table Expressions (CTE). For example:

WITH CTE AS

(

SELECT * FROM TABLE WHERE ID= @ID

UNINON ALL

SELECT T1.* FROM TABLE T1, CET T2

WHERE T1.ParentID = T2.id

)

SELECT * FROM CTE



Note: The test is based on the sample databases and projects here:

http://www.codeplex.com/Wiki/View.aspx?ProjectName=SqlServerSamples



Microsoft SQL Server TechNet Forum Support Team | Part III

Reporting Services



71



Part III: Reporting Services



How do I set interactive sort across multiple groups in SSRS

2005?

Answer

One possible workaround is using drill-through action to create a fake

‘interactive sort’:

1. Copy and paste the table1 to create a table2.

2. Select the table1, click and edit each group, switch to the Sorting tab, select

a proper column with Ascending/Descending direction for sorting. Select the

table2, click and edit each group, sort the records with a different direction.

3. Click the cell which contains the interactive_sort button in table1, add a new

column to the left. Merge the cells in these two columns row by row except

the table header. After that remove the interactive sort from the table1 by

unchecking the option “Add an interactive sort action to this textbox”.

Repeat this step for table2.

4. Create a hidden parameter for the report named Sorting. Set the default

value for this parameter to be “Ascending”.

5. Right click the new added cell in the header of the table1, click properties,

and switch to Navigation tab. Select the “Jump to report”, choose the

current report, set the parameter value of @Sorting to be: “Descending”.

After that, select table1, click properties, switch to Visibility tab, set the

visibility

with

expression:

‘=iif(Parameters!Sorting.Value="Ascending",false,true)”.

6. Right click the new cell in table2, click properties, and switch to Navigation

tab. Select the “Jump to report”, choose the current report, set the

parameter value of @Sorting to be “Ascending”. After that, select table2,

click properties, switch to Visibility tab, set the visibility with expression:

‘=iif(Parameters!Sorting.Value=" Descending",false,true)’.

7. You can merge the cells in these two columns except the cells in header. You

can also create two pictures for those two cells, one for Descending and one

for Ascending. After that, set drill through action on these two pictures.

For matrix, there are some differences.

a) Since the sorting button must be a static cell and you cannot split the matrix

header in SSRS 2005, you can only set interactive sort on matrix header (left

top corner) in SSRS 2005. But in SSRS 2008, you have multiple choices since it

has multiple matrix headers.

b) You cannot sort the detail data in matrix since there is only one detail cell in

one column group and one row group for a matrix. For example, look at the

below matrix

Microsoft SQL Server TechNet Forum Support Team | Part III

Reporting Services



72



Part III: Reporting Services



Matrix Header



A



B



C



1



2



D



3



4



There is only one value 1 for (A, C), so sorting that value is no meaningful. And

even if you can sort the values (1 and 3) on the column A, you will find that the

sort will also impact on the column B, that means 2 and 4 will be also sorted. So

you can only sort on groups or subtotals – (sort X-axis or Y-axis).

For sorting row/column group, right click the matrix header, click properties, and

then switch to the Interactive Sort tab, and set the sorting group region and

sorting expression. In Reporting Services 2005, if the row/column group is not in

the drop down list of ‘evaluate sort expression’, you can type the row/column

group name in that textbox.

After that, if you want to set the interactive sort for row group and column group

at one time, you can try the above work around (for table) – using drill through

action. Create two matrixes, right click the group, click edit group, sort the

groups in sort tab of, and then create drill through with parameter.



Microsoft SQL Server TechNet Forum Support Team | Part III

Reporting Services



73



Part III: Reporting Services



How do I get distinct values of SharePoint column using

SQL Server Reporting Services?

Answer

You can use custom code to get distinct records.

Here are the detailed steps:

1. Create a new dataset same as the main dataset, and then create a hidden

parameter that gets all the records in one field of the new dataset.

2. Create a function that used to remove the duplicate records.

Here is the code:

Public Shared Function RemoveDups(ByVal items As String) As String

Dim noDups As New System.Collections.ArrayList()

Dim SpStr

SpStr = Split(items ,",")

For i As Integer=0 To Ubound(Spstr)

If Not noDups.Contains(SpStr(i).Trim()) Then

noDups.Add(SpStr(i).Trim())

End If

Next

Dim uniqueItems As String() = New String(noDups.Count-1){}

noDups.CopyTo(uniqueItems)

Return String.Join(",", uniqueItems)

End Function



3. Create another parameter that will be used for filtering the main data.

Please set the available value to be

=Split(Code.RemoveDups(JOIN(Parameters!ISSUE_STATUS_TEMP.Value, ",")),

",")

And the default value to be the value you wanted, such as the first value:

=Split(Code.RemoveDups(JOIN(Parameters!ISSUE_STATUS_TEMP.Value, ",")),

",").(0)

4. Select the main dataset and open the property window of this dataset.

5. In the “Filters” tab, set the filter to be:

Expression:

Operator: =

Microsoft SQL Server TechNet Forum Support Team | Part III

Reporting Services



74



Part III: Reporting Services



Value: =Parameters!Region.Value



The parameter “Region” should be the parameter we created in the step3. Now,

we could get the distinct values of SharePoint columns.



How do I resolve the printer problem “Unable to load

client print control”?

Answer

The issue could be caused if the RSClientPrint control has been updated after the

Report Server got updated.

The Reporting Services uses the CLSID of the RSClientPrint control and a function

in the control to check if the RSClientPrint control has been installed in the client.

If the CLSID is not the one the server required, the server will throw the

exception “Unable to load client print control”.

For example, the old CLSID is “{FA91DF8D-53AB-455D-AB20-F2F023E498D3}”.

After applying SQL Server 2005 Service Pack2 or later, the CLSID should be

“{41861299-EAB2-4DCC-986C-802AE12AC499}”. If the client has the control with

the ID “{FA91DF8D-53AB-455D-AB20-F2F023E498D3}”, and the server has been

updated, then we will encounter the error.

I would suggest using the following steps to solve the issue:

1. Install Windows Resource Kits.

2. Use the “oleview.exe” to check if the RSClientPrint 2005 Class (Object Class

-- > Grouped by Component Category -- > Controls) has been installed.

3. If the control has been installed in the client, please remember its CLSID that

is displayed in the right window of OLEVIEW.

4. Open Internet Explorer

5. Click “Tools” -- > “Manage Add-ons” to manage add-ons.

6. Select “All add-ons”, and then select “RSClientPrint 2005 Class”

7. Click “Delete” to delete the control. Or “Disable” to disable the control.

8. Re-run a report, and click Print. Now the RSClientPrint control will work fine.

9. Re-open the OLEVIEW to check the newer CLSID.

If the new CLSID is different from the old one, the issue is the one we have

described above.

Reference



Microsoft SQL Server TechNet Forum Support Team | Part III

Reporting Services



75



Part III: Reporting Services



Window Resource Kits:

http://www.microsoft.com/downloads/details.aspx?familyid=9d467a69-57ff-4ae

7-96ee-b18c4790cffd&displaylang=en

"Unable to load client print control" after installing a Service Pack or Cumulative

Update of SQL Server 2005:

http://blogs.msdn.com/mariae/archive/2008/12/11/unable-to-load-client-printcontrol-after-install-a-service-pack-or-cumulative-update-of-sql-server-2005.aspx



How do I allow Enter key to act like the “view report”

button?

Answer

While clicking the “View Report” button, the report sever uses JavaScript to

verify the parameters and submit the action. There, the report manager uses the

“Report.aspx” to display the parameter panel, and the report server uses the

“ReportViewer.aspx” to display the parameter panel. We can implement a

custom function using JavaScript that allows us to view the report by Enter key.

Please follow these steps to allow Enter key to act like “View Report” button:

1. Open the “Report.aspx” using notepad.

By default, the file located at:

C:\Program Files\Microsoft SQL Server\MSSQL.3\Reporting Services\

ReportManager\Pages

2. At the end of the file, embed the following code.

Tải bản đầy đủ (.pdf) (182 trang)

×