Sunday, February 19, 2012

Dynamic columns

My report has a large number of rows in the details section, This wastes a lot of space. I'd like to spread these rows across multiple columns in the details section of my table.

What i'm currently getting...

ROW1-

ROW2-

ROW3-

ROW4-

ROW5-

ROW6-

ROW7-

ROW*-

ROW9-

What I'd like to see...

ROW1- ROW2- ROW3-

ROW4- ROW5- ROW6-

ROW7- ROW8- ROW9-

Is this possible, if so, how?

SSRS supports multi-column reports.

|||Thanks for your reply, but the example in that link doesnt really suit me. My report has various groups and footer totals that are independent of the "details" columns. I need to, somehow, break the 'details' into 3 columns, while still maintaining my header,subreport, groups, and footer|||

Perhaps a multi-column subreport for the details only then.

|||

Using a Matrix:

Save this as an RDL file and figure out whats going on.

Code Snippet

<?xml version="1.0" encoding="utf-8"?>

<Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2005/01/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">

<DataSources>

<DataSource Name="AdventureWorks">

<DataSourceReference>AdventureWorks</DataSourceReference>

<rd:DataSourceID>05fe442d-a63b-47f0-9339-790445d10db9</rd:DataSourceID>

</DataSource>

</DataSources>

<BottomMargin>1in</BottomMargin>

<RightMargin>1in</RightMargin>

<rd:DrawGrid>true</rd:DrawGrid>

<InteractiveWidth>8.5in</InteractiveWidth>

<rd:SnapToGrid>true</rd:SnapToGrid>

<Body>

<ReportItems>

<Matrix Name="matrix1">

<MatrixColumns>

<MatrixColumn>

<Width>1in</Width>

</MatrixColumn>

</MatrixColumns>

<RowGroupings>

<RowGrouping>

<Width>1in</Width>

<DynamicRows>

<ReportItems>

<Textbox Name="textbox3">

<rd:DefaultName>textbox3</rd:DefaultName>

<ZIndex>1</ZIndex>

<Style>

<PaddingLeft>2pt</PaddingLeft>

<PaddingBottom>2pt</PaddingBottom>

<PaddingRight>2pt</PaddingRight>

<PaddingTop>2pt</PaddingTop>

</Style>

<CanGrow>true</CanGrow>

<Value />

</Textbox>

</ReportItems>

<Grouping Name="matrix1_ROWGROUPS">

<GroupExpressions>

<GroupExpression>=Fields!ROWGROUPS.Value</GroupExpression>

</GroupExpressions>

</Grouping>

</DynamicRows>

</RowGrouping>

</RowGroupings>

<ColumnGroupings>

<ColumnGrouping>

<DynamicColumns>

<ReportItems>

<Textbox Name="COLUMNGROUPS">

<rd:DefaultName>COLUMNGROUPS</rd:DefaultName>

<ZIndex>2</ZIndex>

<Style>

<TextAlign>Right</TextAlign>

<PaddingLeft>2pt</PaddingLeft>

<PaddingBottom>2pt</PaddingBottom>

<PaddingRight>2pt</PaddingRight>

<PaddingTop>2pt</PaddingTop>

</Style>

<CanGrow>true</CanGrow>

<Value>=Fields!COLUMNGROUPS.Value</Value>

</Textbox>

</ReportItems>

<Grouping Name="matrix1_COLUMNGROUPS">

<GroupExpressions>

<GroupExpression>=Fields!COLUMNGROUPS.Value</GroupExpression>

</GroupExpressions>

</Grouping>

</DynamicColumns>

<Height>0.25in</Height>

</ColumnGrouping>

</ColumnGroupings>

<DataSetName>DataSet1</DataSetName>

<Corner>

<ReportItems>

<Textbox Name="textbox1">

<rd:DefaultName>textbox1</rd:DefaultName>

<ZIndex>3</ZIndex>

<Style>

<PaddingLeft>2pt</PaddingLeft>

<PaddingBottom>2pt</PaddingBottom>

<PaddingRight>2pt</PaddingRight>

<PaddingTop>2pt</PaddingTop>

</Style>

<CanGrow>true</CanGrow>

<Value />

</Textbox>

</ReportItems>

</Corner>

<MatrixRows>

<MatrixRow>

<Height>0.25in</Height>

<MatrixCells>

<MatrixCell>

<ReportItems>

<Textbox Name="ROWDATA">

<rd:DefaultName>ROWDATA</rd:DefaultName>

<Style>

<TextAlign>Right</TextAlign>

<PaddingLeft>2pt</PaddingLeft>

<PaddingBottom>2pt</PaddingBottom>

<PaddingRight>2pt</PaddingRight>

<PaddingTop>2pt</PaddingTop>

</Style>

<CanGrow>true</CanGrow>

<Value>=First(Fields!ROWDATA.Value)</Value>

</Textbox>

</ReportItems>

</MatrixCell>

</MatrixCells>

</MatrixRow>

</MatrixRows>

</Matrix>

</ReportItems>

<Height>0.5in</Height>

</Body>

<rd:ReportID>327962be-8654-4648-a50f-65e063317681</rd:ReportID>

<LeftMargin>1in</LeftMargin>

<DataSets>

<DataSet Name="DataSet1">

<Query>

<rd:UseGenericDesigner>true</rd:UseGenericDesigner>

<CommandText>SELECT 'ROW1' AS ROWDATA, 1 AS ROWGROUPS, 1 AS COLUMNGROUPS

UNION ALL

SELECT 'ROW2' AS ROWDATA, 1 AS ROWGROUPS, 2 AS COLUMNGROUPS

UNION ALL

SELECT 'ROW3' AS ROWDATA, 1 AS ROWGROUPS, 3 AS COLUMNGROUPS

UNION ALL

SELECT 'ROW4' AS ROWDATA, 2 AS ROWGROUPS, 1 AS COLUMNGROUPS

UNION ALL

SELECT 'ROW5' AS ROWDATA, 2 AS ROWGROUPS, 2 AS COLUMNGROUPS

UNION ALL

SELECT 'ROW6' AS ROWDATA, 2 AS ROWGROUPS, 3 AS COLUMNGROUPS

UNION ALL

SELECT 'ROW7' AS ROWDATA, 3 AS ROWGROUPS, 1 AS COLUMNGROUPS

UNION ALL

SELECT 'ROW8' AS ROWDATA, 3 AS ROWGROUPS, 2 AS COLUMNGROUPS

UNION ALL

SELECT 'ROW9' AS ROWDATA, 3 AS ROWGROUPS, 3 AS COLUMNGROUPS</CommandText>

<DataSourceName>AdventureWorks</DataSourceName>

</Query>

<Fields>

<Field Name="ROWDATA">

<rd:TypeName>System.String</rd:TypeName>

<DataField>ROWDATA</DataField>

</Field>

<Field Name="ROWGROUPS">

<rd:TypeName>System.Int32</rd:TypeName>

<DataField>ROWGROUPS</DataField>

</Field>

<Field Name="COLUMNGROUPS">

<rd:TypeName>System.Int32</rd:TypeName>

<DataField>COLUMNGROUPS</DataField>

</Field>

</Fields>

</DataSet>

</DataSets>

<Width>2in</Width>

<InteractiveHeight>11in</InteractiveHeight>

<Language>en-US</Language>

<TopMargin>1in</TopMargin>

</Report>

No comments:

Post a Comment