總計、彙總與內建集合的運算式範圍Expression Scope for Totals, Aggregates, and Built-in Collections

撰寫運算式時,您會發現 「範圍」 (Scope) 一詞用於多個內容。When you write expressions, you will find that the term scope is used in multiple contexts. 範圍可以指定要用於評估運算式的資料、轉譯頁面上的文字方塊集合、可以根據切換顯示或隱藏之報表項目的集合。Scope can specify the data to use for evaluating an expression, the set of text boxes on a rendered page, the set of report items that can be shown or hidden based on a toggle. 您將會在與運算式評估、彙總函式語法、條件式可用性相關的主題中,以及與這些領域相關的錯誤訊息中看 「範圍」 (Scope) 一詞。You will see the term scope in topics that relate to expression evaluation, aggregate function syntax, conditional visibility, and also in error messages related to these areas. 使用下列描述來協助區分 「範圍」 (Scope) 適用的意義:Use the following descriptions to help differentiate which meaning of scope applies:

  • 資料範圍 :資料範圍是報表處理器所使用的範圍階層,因為它會結合報表資料和報表配置,並建立用來顯示資料的資料區,例如資料表及圖表。Data scope Data scope is a hierarchy of scopes that the report processor uses as it combines report data and report layout, and builds out data regions such as tables and charts on which to display the data. 了解資料範圍可協助您在執行下列動作時得到您希望的結果:Understanding data scope helps you to get the results that you want when you do the following:

    • 撰寫使用彙總函式的運算式 :指定要彙總的資料。Write expressions that use aggregate functions Specify which data to aggregate. 運算式在報表中的位置會影響彙總計算範圍的資料。The location of the expression in the report influences which data is in scope for aggregate calculations.

    • 將走勢圖加入至資料表或矩陣 :指定要對齊資料表或矩陣中之巢狀執行個體的圖表座標軸最小和最大範圍。Add sparklines to a table or matrix Specify a minimum and maximum range for chart axes to align nested instances in a table or matrix.

    • 將指標加入至資料表或矩陣 :指定要對齊資料表或矩陣中之巢狀執行個體的量測計最小和最大刻度。Add indicators to a table or matrix Specify a minimum and maximum scale for the gauge to align nested instances in a table or matrix.

    • 撰寫排序運算式 :指定一個您可以用來同步處理多個相關報表項目之間的排序次序之包含範圍。Write sort expressions Specify a containing scope that you can use to synchronize sort order among multiple related report items.

  • 資料格範圍 :資料格範圍是資料格所屬之 Tablix 資料區中資料列及資料行群組的集合。Cell scope Cell scope is the set of row and column groups in a tablix data region to which a cell belongs. 依預設,每個 Tablix 資料格都包含一個文字方塊。By default, each tablix cell contains a text box. 文字方塊的值為運算式。The value of the text box is the expression. 資料格的位置會間接決定您可以在運算式中針對彙總函式指定的資料範圍。The location of the cell indirectly determines which data scopes you can specify for aggregate calculations in the expression.

  • 報表項目範圍 :報表項目範圍指的是轉譯之報表頁面上的項目集合。Report item scope Report item scope refers to the collection of items on a rendered report page. 報表處理器會結合資料與報表配置元素來產生已編譯的報表定義。The report processor combines data and report layout elements to produce a compiled report definition. 在此程序期間,資料區 (例如資料表和矩陣) 會依需要擴展以顯示所有報表資料。During this process, data regions such as tables and matrices expand as needed to display all of the report data. 接著,報表轉譯器會處理已編譯的報表。The compiled report is then processed by a report renderer. 報表轉譯器會決定每一頁所出現的報表項目。The report renderer determines which report items appear on each page. 在報表伺服器上,當您檢視每個頁面時,系統就會轉譯頁面。On a report server, each page is rendered as you view it. 匯出報表時,所有頁面都會經過轉譯。When you export a report, all pages are rendered. 了解報表項目範圍可協助您在執行下列動作時得到您希望的結果:Understanding report item scope helps you get the results that you want when you do the following:

    • 加入切換項目 :指定文字方塊來加入控制報表項目可見性的切換。Add toggle items Specify a text box to add the toggle that controls the visibility of a report item. 您只能將切換加入至您要切換之報表項目範圍中的文字方塊。You can only add a toggle to text boxes that are in the scope of the report item that you want to toggle.

    • 在頁首與頁尾中撰寫運算式 :在文字方塊或出現在轉譯頁面之其他報表項目中,指定運算式的值。Write expressions in page headers and footers Specify values in expressions in text boxes or other report items that appear on the rendered page.

    了解範圍可協助您成功撰寫能夠提供您希望之結果的運算式。Understanding scopes helps you to successfully write expressions that give you the results that you want.

注意

您可以在報表產生器以及 SQL Server Data Tools 的報表設計師中建立和修改分頁報表定義檔 (.rdl)。You can create and modify paginated report definition (.rdl) files in Report Builder and in Report Designer in SQL Server Data Tools. 每種撰寫環境都會提供不同的方式來建立、開啟和儲存報表與相關的項目。Each authoring environment provides different ways to create, open, and save reports and related items.

了解資料範圍和資料階層Understanding Data Scope and Data Hierarchy

資料範圍會指定一組報表資料。Data scope specifies a set of report data. 資料範圍擁有自然階層以及繼承的內含項目關聯性。Data scope has a natural hierarchy with an inherent containment relationship. 階層上的範圍越高,包含的範圍在階層上越低。Scopes higher on the hierarchy contain scopes that are lower on the hierarchy. 下列資料範圍清單依序描述階層 (資料從最多到最少):The following list of data scopes describes the hierarchy in order from most data to least data:

  • 套用資料集篩選後的資料集 :指定連結到報表主體中之資料區或報表項目的報表資料集。Datasets, after dataset filters are applied Specifies the report dataset linked to the data region or to a report item in the report body. 用於彙總的資料是在套用資料集篩選運算式之後取自報表資料集。The data used for aggregation is from the report dataset after dataset filter expressions are applied. 若是共用資料集,這表示共用資料集定義中的篩選與報表之共用資料集執行個體中的篩選。For shared datasets, this means both the filters in the shared dataset definition and the filters in the shared dataset instance in the report.

  • 資料區域 :指定在套用資料區域篩選和排序運算式之後取自資料區域的資料。Data regions Specifies data from the data region after data region filter and sort expressions are applied. 在計算資料區的彙總時,不會使用群組篩選。Group filters are not used when calculating aggregates for data regions.

  • 套用群組篩選後的資料區群組 :指定在套用群組運算式和群組篩選之後父群組和子群組的資料。Data region groups, after group filters are applied Specifies the data after the group expressions and group filters are applied for the parent group and child groups. 若是資料表,這式資料列和資料行群組。For a table, this is the row and column groups. 若是圖表,這是數列和類別目錄群組。For a chart, this is the series and category groups. 為了識別範圍內含項目,每個父群組都會包含其子群組。For the purposes of identifying scope containment, every parent group contains its child groups.

  • 巢狀資料區域 —針對要加入資料的資料格內容,指定在套用巢狀資料區域篩選和排序運算式之後的巢狀資料區域的資料。Nested data regions Specifies the data for the nested data region in the context of the cell to which it has been added, and after the nested data region filter and sort expressions have been applied.

  • 巢狀資料區域的資料列和資料行群組 :指定在套用巢狀資料區域的群組運算式和群組篩選之後的資料。Row and column groups for the nested data regions Specifies the data after the nested data region group expressions and group filters have been applied.

    撰寫包含彙總函式的運算式時,了解包含和被包含的範圍相當重要。Understanding containing and contained scopes is important when you write expressions that include aggregate functions.

資料格範圍和運算式Cell Scope and Expressions

當您指定範圍時,表示您向報表處理器指示要用於彙總計算的資料。When you specify a scope, you are indicating to the report processor which data to use for an aggregate calculation. 根據運算式和運算式的位置,有效範圍可能是 「包含的範圍」(Containing Scope) (亦稱為父範圍) 或 「被包含的範圍」(Contained Scope) (亦稱為子範圍或巢狀範圍)。Depending on the expression and the location of the expression, valid scopes might be a containing scopes, also known as parent scopes, or a contained scopes, also known as child or nested scopes. 一般而言,您無法在彙總計算中指定個別的群組執行個體。In general, you cannot specify an individual group instance in an aggregate calculation. 您可以跨所有群組執行個體指定彙總。You can specify an aggregate across all group instances.

報表處理器會結合來自報表資料集中的資料以及 Tablix 資料區,因此,它會評估群組運算式,並建立表示群組執行個體所需的資料列和資料行。As the report processor combines data from a report dataset with the tablix data region, it evaluates group expressions and creates the rows and columns that are needed to represent the group instances. 在每個 Tablix 資料格中,文字方塊內的運算式值會在資料格範圍的內容中評估。The value of expressions in a text box in each tablix cell is evaluated in the context of the cell scope. 根據 Tablix 結構,資料格可以屬於多個資料列群組和資料行群組。Depending on the tablix structure, a cell can belong to multiple row groups and column groups. 若是彙總函式,您可以使用下列其中一個範圍指定要使用的範圍:For aggregate functions, you can specify which scope to use by using one of the following scopes:

  • 預設範圍 :報表處理器評估運算式時,位於計算範圍中的資料。Default scope The data that is in scope for calculations when the report processor evaluates an expression. 預設範圍資料格或資料點所屬的最內部一組群組。The default scope is the innermost set of groups to which the cell or data point belongs. 若是 Tablix 資料區,此集合可以包含資料列和資料行群組。For a tablix data region, the set can include row and column groups. 若是圖表資料區,此集合可以包含類別目錄和數列群組。For a chart data region, the set can include category and series groups.

  • 具名範圍 :位於運算式範圍中之資料集、資料區或資料區群組的名稱。Named scope The name of a dataset, a data region, or a data region group that is in scope for the expression. 若是彙總計算,您可以指定一個包含的範圍。For aggregate calculations, you can specify a containing scope. 您無法在單一運算式中同時指定資料列群組和資料行群組的具名範圍。You cannot specify a named scope for both a row group and a column group in a single expression. 除非運算式是供彙總使用,否則您無法指定被包含的範圍。You cannot specify a contained scope unless the expression is for an aggregate of an aggregate.

    下列運算式會產生 SellStartDate 與 LastReceiptDate 之間的間隔年數。The following expression generates the interval years between SellStartDate and LastReceiptDate. 這些欄位位於兩個不同的資料集:DataSet1 和 DataSet2 中。These fields are in two different datasets, DataSet1 and DataSet2. First 函式 (報表產生器及 SSRS) 為彙總函式,它會傳回 DataSet1 中 SellStartDate 的第一個值,以及 DataSet2 中 LastReceiptDate 的第一個值。The First Function (Report Builder and SSRS), which is an aggregate function, returns the first value of SellStartDate in DataSet1 and the first value of LastReceiptDate in DataSet2.

    =DATEDIFF(“yyyy”, First(Fields!SellStartDate.Value, "DataSet1"), First(Fields!LastReceiptDate.Value, "DataSet2"))  
    
  • 網域範圍 :也稱為同步處理範圍。Domain scope Also called synchronization scope. 一種資料範圍的類型,適用於巢狀資料區的運算式評估。A type of data scope that applies to expression evaluation for nested data regions. 網域範圍用來跨所有群組執行個體指定彙總,讓系統可以對齊巢狀執行個體並輕鬆進行比較。Domain scope is used to specify aggregates across all instances of a group so that nested instances can be aligned and easily compared. 例如,您可以對齊資料表中內嵌之走勢圖的範圍和高度,讓這些值可以對齊。For example, you can align the range and height for sparklines embedded in a table so that the values line up.

    在某些報表位置,您必須指定一個範圍。In some locations of a report, you must specify a scope. 例如,若是設計介面上的文字方塊,您必須指定要使用的資料集名稱: =Max(Fields!Sales.Value,"Dataset1")For example, for a text box on the design surface, you must specify the name of the dataset to use: =Max(Fields!Sales.Value,"Dataset1"). 在某些位置,則有一個隱含的預設範圍。In other locations, there is an implicit default scope. 例如,如果您沒有在群組範圍中指定文字方塊的彙總,則會先使用預設彙總。For example, if you do not specify an aggregate for a text box in a group scope, the default aggregate First is used.

    每個彙總函式主題都會列出適用於其用途的範圍。Each aggregate function topic lists the scopes that are valid for its use. 如需詳細資訊,請參閱 彙總函式參考 (報表產生器和 SSRS)For more information, see Aggregate Functions Reference (Report Builder and SSRS).

資料表資料區的彙總運算式範例Example Aggregate Expressions for a Table Data Region

撰寫指定非預設範圍的運算式需要一些練習。To write expressions that specify non-default scopes takes some practice. 為協助您了解不同範圍,請使用下列圖表與資料表。To help you understand different scopes, use the following figure and table. 此圖表會在銷售資訊資料表中標示每個資料格,依年度和季度以及銷售領域顯示銷售的項目數量。The figure labels each cell in a sales information table that displays quantity of items sold by year and quarter and also by sales territory. 請注意顯示資料列與資料行群組結構之資料列控制代碼和資料行控制代碼上,表示巢狀群組的視覺提示。Note the visual cues on the row handles and column handles that display row and column group structure, indicating nested groups. 資料表的結構如下:The table has the following structure:

  • 包含邊角資料格與三個資料列 (包括資料行群組標頭) 的資料表標頭。A table header that contains the corner cell and three rows that include the column group headers.

  • 以名稱為 Cat 之類別目錄和名稱為 SubCat 之子類別目錄為基礎的兩個巢狀資料列群組。Two nested row groups based on category named Cat and subcategory named SubCat.

  • 以名稱為 Year 之年度與名稱為 Qtr 之季度為基礎的兩個巢狀資料行群組。Two nested column groups based on year named Year and quarter named Qtr.

  • 標示為 Totals 的一個靜態總計資料行。One static totals column labeled Totals.

  • 以名稱為 Territory 之銷售領域為基礎的一個相鄰資料行群組。One adjacent column group based on sales territory named Territory.

    領域群組的資料行標頭已針對顯示用途,分成兩個資料格。The column header for the territory group has been split into two cells for display purposes. 第一個資料格會顯示領域名稱與總計,而第二個資料格中的預留位置文字會針對每個領域計算所有銷售量所佔的百分比。The first cell displays the territory name and totals, and the second cell has placeholder text that calculated the percentage contribution for each territory to all sales.

    rs_BasicTableSumCellScopers_BasicTableSumCellScope

    假設資料集的名稱為 DataSet1,而資料表的名稱為 Tablix1。Assume the dataset is named DataSet1 and the table is named Tablix1. 下表列出資料格標籤、預設範圍和範例。The following table lists the cell label, the default scope, and examples. 預留位置文字的值會以運算式語法顯示。The values for placeholder text are shown by in expression syntax.

資料格Cell 預設範圍Default scope 預留位置標籤Placeholder labels 文字或預留位置的值Text or placeholder values
C01C01 Tablix1Tablix1 [Sum(Qty)][Sum(Qty)] 彙總和範圍Aggregates and Scope

=Sum(Fields!Qty.Value)
C02C02 外部資料行群組 "Year"Outer column group "Year" [Year][Year]

([YearQty])([YearQty])
=Fields!Year.Value

=Sum(Fields!Qty.Value)
C03C03 Tablix1Tablix1 [Sum(Qty)][Sum(Qty)] 總計Totals

=Sum(Fields!Qty.Value)
C04C04 對等資料行群組 "Territory"Peer column group "Territory" ([Total])([Total]) TerritoryTerritory

=Sum(Fields!Qty.Value)
C05C05 內部群組 "Qtr"Inner group "Qtr" [Qtr][Qtr]

([QtrQty])([QtrQty])
QQ

=Fields!Qtr.Value

=Sum(Fields!Qty.Value)
C06C06 對等資料行群組 "Territory"Peer column group "Territory" [Territory][Territory]

([Tty])([Tty])

[Pct][Pct]
=Fields!Territory.Value

=Sum(Fields!Qty.Value)

=FormatPercent(Sum(Fields!Qty.Value,"Territory")/Sum(Fields!Qty.Value,"Tablix1"),0) & " of " & Sum(Fields!Qty.Value,"Tablix1")
C07C07 外部資料列群組 "Cat"Outer row group "Cat" [Cat][Cat]

[Sum(Qty)][Sum(Qty)]
=Fields!Cat.Value

=Sum(Fields!Qty.Value)
C08C08 與 C07 相同Same as C07
C09C09 外部資料列群組 "Cat" 和內部資料行群組 "Qtr"Outer row group "Cat" and inner column group "Qtr" [Sum(Qty)][Sum(Qty)] =Sum(Fields!Qty.Value)
C10C10 與 C07 相同Same as C07 <<Expr>><<Expr>> =Sum(Fields!Qty.Value) & ": " & FormatPercent(Sum(Fields!Qty.Value)/Sum(Fields!Qty.Value,"Tablix1"),0) & " of " & Sum(Fields!Qty.Value,"Tablix1")
C11C11 外部資料列群組 "Cat" 和資料行群組 "Territory"Outer row group "Cat" and column group "Territory" <<Expr>><<Expr>> =Sum(Fields!Qty.Value) & ": " & FormatPercent(Sum(Fields!Qty.Value)/Sum(Fields!Qty.Value,"Territory"),0) & " of " & Sum(Fields!Qty.Value,"Territory")
C12C12 內部資料列群組 "Subcat"Inner row group "Subcat" [Subcat][Subcat]

[Sum(Qty)][Sum(Qty)]
=Fields!SubCat.Value

=Sum(Fields!Qty.Value)
C13C13 內部資料列群組 "Subcat" 和內部資料行群組 "Qtr"Inner row group "Subcat" and inner column group "Qtr" [Sum(Qty)][Sum(Qty)] =Sum(Fields!Qty.Value)
C14C14 內部資料列群組 "Subcat"Inner row group "Subcat" <<Expr>><<Expr>> =Sum(Fields!Qty.Value) & ": " & FormatPercent(Sum(Fields!Qty.Value)/Sum(Fields!Qty.Value,"Cat"),0) & " of " & Sum(Fields!Qty.Value,"Cat")
C15C15 內部資料列群組 "Subcat" 和資料行群組 "Territory"Inner row group "Subcat" and column group "Territory" <<Expr>><<Expr>> =Sum(Fields!Qty.Value) & ": " & FormatPercent(Code.CalcPercentage(Sum(Fields!Qty.Value),Sum(Fields!Qty.Value,"Cat")),0) & " of " & Sum(Fields!Qty.Value,"Cat")

如需解譯 Tablix 資料區之視覺提示的詳細資訊,請參閱 Tablix 資料區域資料格、資料列及資料行 (報表產生器及 SSRS)For more information about interpreting visual cues on tablix data regions, see Tablix Data Region Cells, Rows, and Columns (Report Builder) and SSRS. 如需 Tablix 資料區的詳細資訊,請參閱 Tablix 資料區域資料格、資料列及資料行 (報表產生器及 SSRS)For more information about the tablix data region, see Tablix Data Region Cells, Rows, and Columns (Report Builder) and SSRS. 如需運算式和彙總的詳細資訊,請參閱報表中的運算式用法 (報表產生器及 SSRS)彙總函式參考 (報表產生器及 SSRS)For more information about expressions and aggregates, see Expression Uses in Reports (Report Builder and SSRS) and Aggregate Functions Reference (Report Builder and SSRS).

同步處理走勢圖的縮放比例Synchronizing Scales for Sparklines

若要針對內嵌在資料表或矩陣中的走勢圖,跨時間比較水平軸上的值,您可以同步處理類別目錄群組值。To compare values across time on the horizontal axis for a sparkline chart that is nested in a table or matrix, you can synchronize the category group values. 這稱為對齊座標軸。This is called aligning axes. 透過選取要對齊座標軸的選項,報表會自動設定座標軸的最小值和最大值,並提供預留位置給不存在於每個類別目錄中的彙總值。By selecting the option to align axes, the report automatically sets minimum and maximum values for an axis, and provides placeholders for aggregate values that do not exist in every category. 這會使走勢圖中的值跨每個類別目錄對齊,並讓您比較彙總資料之每個資料列的值。This causes the values in the sparkline to line up across every category and enables you to compare values for each row of aggregated data. 透過選取這個選項,表示您要從運算式評估的範圍變更為 「網域範圍」(Domain Scope)。By selecting this option, you are changing the scope of the expression evaluation to the domain scope. 設定巢狀圖表的網域範圍也會間接地控制每個類別目錄在圖例中的色彩指派。Setting the domain scope for a nested chart also indirectly controls the color assignment for each category in the legend.

例如,在顯示每週趨勢的走勢圖中,假設某個城市有 3 個月的銷售資料,而另一個城市有 12 個月的銷售資料。For example, in a sparkline that shows weekly trends, suppose that one city had sales data for 3 months and another city had sales data for 12 months. 如果沒有同步處理的縮放比例,第一個城市的走勢圖只會有 3 個橫條,而且這 3 個橫條會比較寬,所佔用的空間會與第二個城市 12 個月的橫條相同。Without synchronized scales, the sparkline for first city would only have 3 bars and they would be much wider and occupy the same space as the 12 month set of bars for the second city.

如需詳細資訊,請參閱在資料表或矩陣的圖表上對齊資料 (報表產生器及 SSRS)For more information, see Align the Data in a Chart in a Table or Matrix (Report Builder and SSRS).

同步處理指標的範圍Synchronizing Ranges for Indicators

若要指定用於一組指標的資料值,您必須指定一個範圍。To specify the data values to use for a set of indicators, you must specify a scope. 根據包含指標之資料區的配置,您可以指定一個範圍或一個包含的範圍。Depending on the layout of the data region that contains the indicator, you specify a scope or a containing scope. 例如,在與 sales 類別目錄相關聯的群組標頭資料列中,一組箭頭 (向上、向下、側邊) 可以表示相對於臨界值的銷售值。For example, in a group header row associated with category sales, a set of arrows (up, down, sideways) can indicate sales values relative to a threshold. 包含的範圍是包含指標之資料表或矩陣的名稱。The containing scope is the name of the table or matrix that contains the indicators.

如需詳細資訊,請參閱 設定同步處理範圍 (報表產生器及 SSRS)For more information, see Set Synchronization Scope (Report Builder and SSRS).

從頁首或頁尾指定範圍Specifying Scopes from the Page Header or Page Footer

若要在每個報表頁面上顯示不同的資料,您要將運算式加入至必須位於轉譯頁面上的報表項目中。To display data that is different on each page of a report, you add expressions to a report item that must be on the rendered page. 報表在轉譯時會分成好幾頁,因此,只有在轉譯期間可以決定要存在於頁面上的項目。Because a report is split into pages while it is rendered, only during rendering can it be determined which items exist on a page. 例如,詳細資料列中的資料格所擁有的文字方塊在一個頁面上有多個執行個體。For example, a cell in a detail row has a text box that has many instances on a page.

基於此目的,有一個稱為 ReportItems 的全域集合。For this purpose, there is a global collection called ReportItems. 這是在目前頁面上的文字方塊集合。This is the set of text boxes on the current page.

如需詳細資訊,請參閱頁首和頁尾 (報表產生器及 SSRS)ReportItems 集合參考 (報表產生器及 SSRS)For more information, see Page Headers and Footers (Report Builder and SSRS) and ReportItems Collection References (Report Builder and SSRS).

指定向下鑽研和條件式可見性的切換項目Specifying a Toggle Item for Drilldown and Conditional Visibility

切換是加入到文字方塊中的加號或減號影像,使用者按一下就可以顯示或隱藏其他報表項目。Toggles are plus or minus sign images that are added to a text box and that a user can click to show or hide other report items. 在多數報表項目屬性的 [可見性] 頁面上,您可以指定要加入切換的目標報表項目。On the Visibility page for most report item properties, you can specify which report item to add the toggle to. 切換項目所在的內含項目範圍必須比要顯示或隱藏的項目高。The toggle item must be in a higher containment scope than the item to show or hide.

在 Tablix 資料區中,若要建立向下鑽研效果,讓您按一下某個文字方塊就可以展開資料表來顯示更多資料,您必須在群組上設定 [可見性] 屬性,然後在與包含的群組相關聯之群組標頭中選取一個文字方塊做為切換。In a tablix data region, to create a drilldown effect where you click a text box to expand the table to show more data, you must set the Visibility property on the group, and select as the toggle a text box in a group header that is associated with a containing group.

如需詳細資訊,請參閱 將展開或摺疊動作加入項目中 (報表產生器及 SSRS)For more information, see Add an Expand or Collapse Action to an Item (Report Builder and SSRS).

指定要同步處理排序次序的排序運算式Specifying a Sort Expression to Synchronize Sort Order

當您將互動式排序按鈕加入至資料表資料行時,您可以針對擁有通用包含範圍的多個項目,同步處理排序。When you add an interactive sort button to a table column, you can synchronize sorting for multiple items that have a common containing scope. 例如,您可以將排序按鈕加入至矩陣中的資料行標頭,然後指定包含的範圍做為繫結至矩陣之資料集的名稱。For example, you can add a sort button to a column header in a matrix, and specify the containing scope as the name of the dataset that is bound to the matrix. 當使用者按一下排序按鈕時,除了會排序矩陣資料列之外,也會排序繫結至相同資料集之圖表的圖表數列群組。When a user clicks the sort button, not only are the matrix rows sorted, but also the chart series groups of charts that are bound to the same datset are sorted. 利用這個方式,與該資料集相依的所有資料區都可以進行同步處理,以顯示相同的排序次序。In this way, all data regions that depend on that dataset can be synchronized to show the same sort order.

如需詳細資訊,請參閱 篩選、分組和排序資料 (報表產生器及 SSRS)(將互動式排序加入資料表或矩陣 (報表產生器及 SSRS))。For more information, see Filter, Group, and Sort Data (Report Builder and SSRS).

在資料格中隱藏 Null 或零值Suppressing Null or Zero Values in a Cell

對於許多報表而言,群組範圍的計算可能會建立許多值為零 (0) 或 Null 的資料格。For many reports, calculations that are scoped to groups can create many cells that have zero (0) or null values. 為減少報表中混亂的情形,加入一個運算式,以便在彙總值為 0 時,傳回空白。To reduce clutter in your report, add an expression to return blanks if the aggregate value is 0. 如需詳細資訊,請參閱 運算式範例 (報表產生器及 SSRS)For more information, see "Examples that Suppress Null or Zero Values" in Expression Examples (Report Builder and SSRS).

另請參閱See Also

運算式範例 (報表產生器及 SSRS) Expression Examples (Report Builder and SSRS)
群組運算式範例 (報表產生器及 SSRS) Group Expression Examples (Report Builder and SSRS)
建立遞迴階層群組 (報表產生器及 SSRS) Creating Recursive Hierarchy Groups (Report Builder and SSRS)
資料表、矩陣和清單 (報表產生器及 SSRS) Tables, Matrices, and Lists (Report Builder and SSRS)
格式化文字和預留位置 (報表產生器及 SSRS)Formatting Text and Placeholders (Report Builder and SSRS)