0

使用 Reporting Services 2008 r2。

在 Reporting Services 报表中,我有一个包含两个分组的表:A 组和 B 组。为了显示度量,使用了 Detail 组。

B 组设置为切换 A 组中的值。

示例:A 组是汽车品牌,B 组是汽车型号。在详细信息中显示了利润。最初仅显示汽车品牌列表,并可以展开(切换)并显示汽车型号。从而将利润分成车型。

而现在的问题。在利润列上,交互式排序功能用于按利润对表中的值进行排序,其中包含 2 组。到目前为止,我只设法对 A 组或 B 组进行了排序。这不是我们想要的。我想要的是按利润对整个表格进行排序,A 组和 B 组仍然保持分组。

Reporting Services 是否支持此功能?

提前致谢。

基于冒险作品的报告(.rdl)代码示例:

<?xml version="1.0" encoding="utf-8"?>
<Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
  <Body>
<ReportItems>
  <Tablix Name="Tablix1">
    <TablixBody>
      <TablixColumns>
        <TablixColumn>
          <Width>2.5cm</Width>
        </TablixColumn>
      </TablixColumns>
      <TablixRows>
        <TablixRow>
          <Height>0.6cm</Height>
          <TablixCells>
            <TablixCell>
              <CellContents>
                <Textbox Name="Textbox1">
                  <CanGrow>true</CanGrow>
                  <UserSort>
                    <SortExpression>=Fields!Gross_Profit.Value</SortExpression>
                    <SortExpressionScope>Subcategory</SortExpressionScope>
                  </UserSort>
                  <KeepTogether>true</KeepTogether>
                  <Paragraphs>
                    <Paragraph>
                      <TextRuns>
                        <TextRun>
                          <Value>Gross Profit</Value>
                          <Style />
                        </TextRun>
                      </TextRuns>
                      <Style />
                    </Paragraph>
                  </Paragraphs>
                  <rd:DefaultName>Textbox1</rd:DefaultName>
                  <Style>
                    <Border>
                      <Color>LightGrey</Color>
                      <Style>Solid</Style>
                    </Border>
                    <PaddingLeft>2pt</PaddingLeft>
                    <PaddingRight>2pt</PaddingRight>
                    <PaddingTop>2pt</PaddingTop>
                    <PaddingBottom>2pt</PaddingBottom>
                  </Style>
                </Textbox>
              </CellContents>
            </TablixCell>
          </TablixCells>
        </TablixRow>
        <TablixRow>
          <Height>0.6cm</Height>
          <TablixCells>
            <TablixCell>
              <CellContents>
                <Textbox Name="Textbox13">
                  <CanGrow>true</CanGrow>
                  <KeepTogether>true</KeepTogether>
                  <Paragraphs>
                    <Paragraph>
                      <TextRuns>
                        <TextRun>
                          <Value>=Sum(Fields!Gross_Profit.Value)</Value>
                          <Style>
                            <Format>#,0</Format>
                          </Style>
                        </TextRun>
                      </TextRuns>
                      <Style />
                    </Paragraph>
                  </Paragraphs>
                  <rd:DefaultName>Textbox13</rd:DefaultName>
                  <Style>
                    <Border>
                      <Color>LightGrey</Color>
                      <Style>Solid</Style>
                    </Border>
                    <PaddingLeft>2pt</PaddingLeft>
                    <PaddingRight>2pt</PaddingRight>
                    <PaddingTop>2pt</PaddingTop>
                    <PaddingBottom>2pt</PaddingBottom>
                  </Style>
                </Textbox>
              </CellContents>
            </TablixCell>
          </TablixCells>
        </TablixRow>
        <TablixRow>
          <Height>0.6cm</Height>
          <TablixCells>
            <TablixCell>
              <CellContents>
                <Textbox Name="Gross_Profit">
                  <CanGrow>true</CanGrow>
                  <KeepTogether>true</KeepTogether>
                  <Paragraphs>
                    <Paragraph>
                      <TextRuns>
                        <TextRun>
                          <Value>=Fields!Gross_Profit.Value</Value>
                          <Style>
                            <Format>#,0</Format>
                          </Style>
                        </TextRun>
                      </TextRuns>
                      <Style />
                    </Paragraph>
                  </Paragraphs>
                  <rd:DefaultName>Gross_Profit</rd:DefaultName>
                  <Style>
                    <Border>
                      <Color>LightGrey</Color>
                      <Style>Solid</Style>
                    </Border>
                    <PaddingLeft>2pt</PaddingLeft>
                    <PaddingRight>2pt</PaddingRight>
                    <PaddingTop>2pt</PaddingTop>
                    <PaddingBottom>2pt</PaddingBottom>
                  </Style>
                </Textbox>
              </CellContents>
            </TablixCell>
          </TablixCells>
        </TablixRow>
      </TablixRows>
    </TablixBody>
    <TablixColumnHierarchy>
      <TablixMembers>
        <TablixMember />
      </TablixMembers>
    </TablixColumnHierarchy>
    <TablixRowHierarchy>
      <TablixMembers>
        <TablixMember>
          <TablixHeader>
            <Size>2.5cm</Size>
            <CellContents>
              <Textbox Name="Textbox7">
                <CanGrow>true</CanGrow>
                <KeepTogether>true</KeepTogether>
                <Paragraphs>
                  <Paragraph>
                    <TextRuns>
                      <TextRun>
                        <Value>Category</Value>
                        <Style />
                      </TextRun>
                    </TextRuns>
                    <Style />
                  </Paragraph>
                </Paragraphs>
                <rd:DefaultName>Textbox7</rd:DefaultName>
                <Style>
                  <Border>
                    <Color>LightGrey</Color>
                    <Style>Solid</Style>
                  </Border>
                  <PaddingLeft>2pt</PaddingLeft>
                  <PaddingRight>2pt</PaddingRight>
                  <PaddingTop>2pt</PaddingTop>
                  <PaddingBottom>2pt</PaddingBottom>
                </Style>
              </Textbox>
            </CellContents>
          </TablixHeader>
          <TablixMembers>
            <TablixMember>
              <TablixHeader>
                <Size>2.5cm</Size>
                <CellContents>
                  <Textbox Name="Textbox9">
                    <CanGrow>true</CanGrow>
                    <KeepTogether>true</KeepTogether>
                    <Paragraphs>
                      <Paragraph>
                        <TextRuns>
                          <TextRun>
                            <Value>Subcategory</Value>
                            <Style />
                          </TextRun>
                        </TextRuns>
                        <Style />
                      </Paragraph>
                    </Paragraphs>
                    <rd:DefaultName>Textbox9</rd:DefaultName>
                    <Style>
                      <Border>
                        <Color>LightGrey</Color>
                        <Style>Solid</Style>
                      </Border>
                      <PaddingLeft>2pt</PaddingLeft>
                      <PaddingRight>2pt</PaddingRight>
                      <PaddingTop>2pt</PaddingTop>
                      <PaddingBottom>2pt</PaddingBottom>
                    </Style>
                  </Textbox>
                </CellContents>
              </TablixHeader>
              <TablixMembers>
                <TablixMember />
              </TablixMembers>
            </TablixMember>
          </TablixMembers>
          <KeepWithGroup>After</KeepWithGroup>
        </TablixMember>
        <TablixMember>
          <Group Name="Category">
            <GroupExpressions>
              <GroupExpression>=Fields!Category.Value</GroupExpression>
            </GroupExpressions>
          </Group>
          <SortExpressions>
            <SortExpression>
              <Value>=Fields!Category.Value</Value>
            </SortExpression>
          </SortExpressions>
          <TablixHeader>
            <Size>2.5cm</Size>
            <CellContents>
              <Textbox Name="Category">
                <CanGrow>true</CanGrow>
                <KeepTogether>true</KeepTogether>
                <Paragraphs>
                  <Paragraph>
                    <TextRuns>
                      <TextRun>
                        <Value>=Fields!Category.Value</Value>
                        <Style />
                      </TextRun>
                    </TextRuns>
                    <Style />
                  </Paragraph>
                </Paragraphs>
                <rd:DefaultName>Category</rd:DefaultName>
                <Style>
                  <Border>
                    <Color>LightGrey</Color>
                    <Style>Solid</Style>
                  </Border>
                  <PaddingLeft>2pt</PaddingLeft>
                  <PaddingRight>2pt</PaddingRight>
                  <PaddingTop>2pt</PaddingTop>
                  <PaddingBottom>2pt</PaddingBottom>
                </Style>
              </Textbox>
            </CellContents>
          </TablixHeader>
          <TablixMembers>
            <TablixMember>
              <TablixHeader>
                <Size>2.5cm</Size>
                <CellContents>
                  <Textbox Name="Textbox12">
                    <CanGrow>true</CanGrow>
                    <KeepTogether>true</KeepTogether>
                    <Paragraphs>
                      <Paragraph>
                        <TextRuns>
                          <TextRun>
                            <Value>Total</Value>
                            <Style />
                          </TextRun>
                        </TextRuns>
                        <Style />
                      </Paragraph>
                    </Paragraphs>
                    <rd:DefaultName>Textbox12</rd:DefaultName>
                    <Style>
                      <Border>
                        <Color>LightGrey</Color>
                        <Style>Solid</Style>
                      </Border>
                      <PaddingLeft>2pt</PaddingLeft>
                      <PaddingRight>2pt</PaddingRight>
                      <PaddingTop>2pt</PaddingTop>
                      <PaddingBottom>2pt</PaddingBottom>
                    </Style>
                  </Textbox>
                </CellContents>
              </TablixHeader>
              <KeepWithGroup>After</KeepWithGroup>
            </TablixMember>
            <TablixMember>
              <Group Name="Subcategory">
                <GroupExpressions>
                  <GroupExpression>=Fields!Subcategory.Value</GroupExpression>
                </GroupExpressions>
              </Group>
              <SortExpressions>
                <SortExpression>
                  <Value>=Fields!Subcategory.Value</Value>
                </SortExpression>
              </SortExpressions>
              <TablixHeader>
                <Size>2.5cm</Size>
                <CellContents>
                  <Textbox Name="Subcategory">
                    <CanGrow>true</CanGrow>
                    <KeepTogether>true</KeepTogether>
                    <Paragraphs>
                      <Paragraph>
                        <TextRuns>
                          <TextRun>
                            <Value>=Fields!Subcategory.Value</Value>
                            <Style />
                          </TextRun>
                        </TextRuns>
                        <Style />
                      </Paragraph>
                    </Paragraphs>
                    <rd:DefaultName>Subcategory</rd:DefaultName>
                    <Style>
                      <Border>
                        <Color>LightGrey</Color>
                        <Style>Solid</Style>
                      </Border>
                      <PaddingLeft>2pt</PaddingLeft>
                      <PaddingRight>2pt</PaddingRight>
                      <PaddingTop>2pt</PaddingTop>
                      <PaddingBottom>2pt</PaddingBottom>
                    </Style>
                  </Textbox>
                  <rd:Selected>true</rd:Selected>
                </CellContents>
              </TablixHeader>
              <TablixMembers>
                <TablixMember>
                  <Group Name="Details" />
                </TablixMember>
              </TablixMembers>
              <Visibility>
                <Hidden>true</Hidden>
                <ToggleItem>Category</ToggleItem>
              </Visibility>
            </TablixMember>
          </TablixMembers>
        </TablixMember>
      </TablixMembers>
    </TablixRowHierarchy>
    <DataSetName>DataSet1</DataSetName>
    <Height>1.8cm</Height>
    <Width>7.5cm</Width>
    <Style>
      <Border>
        <Style>None</Style>
      </Border>
    </Style>
  </Tablix>
</ReportItems>
<Height>0.70866in</Height>
<Style />
  </Body>
  <Width>2.95276in</Width>
 <Page>
<PageHeight>29.7cm</PageHeight>
<PageWidth>21cm</PageWidth>
<LeftMargin>2cm</LeftMargin>
<RightMargin>2cm</RightMargin>
<TopMargin>2cm</TopMargin>
<BottomMargin>2cm</BottomMargin>
<ColumnSpacing>0.13cm</ColumnSpacing>
<Style />
</Page>
<AutoRefresh>0</AutoRefresh>
<DataSources>
<DataSource Name="DataSource1">
  <DataSourceReference>DataSource1</DataSourceReference>
  <rd:SecurityType>None</rd:SecurityType>
  <rd:DataSourceID>9a3c3555-b858-4735-8414-0856ebe26806</rd:DataSourceID>
</DataSource>
</DataSources>
<DataSets>
<DataSet Name="DataSet1">
  <Query>
    <DataSourceName>DataSource1</DataSourceName>
    <CommandText> SELECT NON EMPTY { [Measures].[Gross Profit] } ON COLUMNS, NON EMPTY { ([Product].[Category].[Category].ALLMEMBERS * [Product].[Subcategory].[Subcategory].ALLMEMBERS ) } DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME ON ROWS FROM [Adventure Works] CELL PROPERTIES VALUE, BACK_COLOR, FORE_COLOR, FORMATTED_VALUE, FORMAT_STRING, FONT_NAME, FONT_SIZE, FONT_FLAGS</CommandText>
    <rd:DesignerState>
      <QueryDefinition xmlns="http://schemas.microsoft.com/AnalysisServices/QueryDefinition">
        <CommandType>MDX</CommandType>
        <QuerySpecification xsi:type="MDXQuerySpecification" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
          <Select>
            <Items>
              <Item>
                <ID xsi:type="Level">
                  <DimensionName>Product</DimensionName>
                  <HierarchyName>Category</HierarchyName>
                  <HierarchyUniqueName>[Product].[Category]</HierarchyUniqueName>
                  <LevelName>Category</LevelName>
                  <UniqueName>[Product].[Category].[Category]</UniqueName>
                </ID>
                <ItemCaption>Category</ItemCaption>
                <UniqueName>true</UniqueName>
              </Item>
              <Item>
                <ID xsi:type="Level">
                  <DimensionName>Product</DimensionName>
                  <HierarchyName>Subcategory</HierarchyName>
                  <HierarchyUniqueName>[Product].[Subcategory]</HierarchyUniqueName>
                  <LevelName>Subcategory</LevelName>
                  <UniqueName>[Product].[Subcategory].[Subcategory]</UniqueName>
                </ID>
                <ItemCaption>Subcategory</ItemCaption>
                <UniqueName>true</UniqueName>
              </Item>
              <Item>
                <ID xsi:type="Measure">
                  <MeasureName>Gross Profit</MeasureName>
                  <UniqueName>[Measures].[Gross Profit]</UniqueName>
                </ID>
                <ItemCaption>Gross Profit</ItemCaption>
                <BackColor>true</BackColor>
                <ForeColor>true</ForeColor>
                <FontFamily>true</FontFamily>
                <FontSize>true</FontSize>
                <FontWeight>true</FontWeight>
                <FontStyle>true</FontStyle>
                <FontDecoration>true</FontDecoration>
                <FormattedValue>true</FormattedValue>
                <FormatString>true</FormatString>
              </Item>
            </Items>
          </Select>
          <From>Adventure Works</From>
          <Filter>
            <FilterItems />
          </Filter>
          <Calculations />
          <Aggregates />
          <QueryProperties />
        </QuerySpecification>
        <Query>
          <Statement> SELECT NON EMPTY { [Measures].[Gross Profit] } ON COLUMNS, NON EMPTY { ([Product].[Category].[Category].ALLMEMBERS * [Product].[Subcategory].[Subcategory].ALLMEMBERS ) } DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME ON ROWS FROM [Adventure Works] CELL PROPERTIES VALUE, BACK_COLOR, FORE_COLOR, FORMATTED_VALUE, FORMAT_STRING, FONT_NAME, FONT_SIZE, FONT_FLAGS</Statement>
          <ParameterDefinitions />
        </Query>
      </QueryDefinition>
    </rd:DesignerState>
  </Query>
  <Fields>
    <Field Name="Category">
      <DataField>&lt;?xml version="1.0" encoding="utf-8"?&gt;&lt;Field xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:type="Level" UniqueName="[Product].[Category].[Category]" /&gt;</DataField>
      <rd:TypeName>System.String</rd:TypeName>
    </Field>
    <Field Name="Subcategory">
      <DataField>&lt;?xml version="1.0" encoding="utf-8"?&gt;&lt;Field xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:type="Level" UniqueName="[Product].[Subcategory].[Subcategory]" /&gt;</DataField>
      <rd:TypeName>System.String</rd:TypeName>
    </Field>
    <Field Name="Gross_Profit">
      <DataField>&lt;?xml version="1.0" encoding="utf-8"?&gt;&lt;Field xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:type="Measure" UniqueName="[Measures].[Gross Profit]" /&gt;</DataField>
      <rd:TypeName>System.Int32</rd:TypeName>
    </Field>
  </Fields>
</DataSet>
</DataSets>
<rd:ReportUnitType>Cm</rd:ReportUnitType>
<rd:ReportID>73334590-ae11-454b-8075-9d8b167ac594</rd:ReportID>
</Report>
4

1 回答 1

1

是的,您可以这样做,您应该再添加一个虚拟父组(GroupA 和 GroupB 的父组),该组将按组 A 中的组字段和 B 中的组字段进行分组。与交互式排序相比,您应该选择该组。在您报告中,您有组类别和子类别,还添加 ParentGroup(分组字段是类别,子类别): 在此处输入图像描述

并删除由该组创建的不必要的单元格。

于 2013-02-12T08:08:47.800 回答