I am using SSRS 2008.
This does not make any sense but it is happening.
I built a report that show invoices based on invoice number.
The problem is that when I move the table up a single pixel it adds a new page in the end (it should not).
I have removed all controls and left just the table and this is still happening.
Can anyone explain to me why this is happening and how to fix it?
Just try it to move the table up a single pixel.
Here is my code:
<?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="table1">
<TablixBody>
<TablixColumns>
<TablixColumn>
<Width>4in</Width>
</TablixColumn>
</TablixColumns>
<TablixRows>
<TablixRow>
<Height>0.21in</Height>
<TablixCells>
<TablixCell>
<CellContents>
<Textbox Name="ITEMDESC">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>=Fields!ITEMDESC.Value</Value>
<Style>
<FontFamily>Calibri</FontFamily>
</Style>
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>ITEMDESC</rd:DefaultName>
<Style>
<Border>
<Style>None</Style>
</Border>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</CellContents>
</TablixCell>
</TablixCells>
</TablixRow>
<TablixRow>
<Height>0.25in</Height>
<TablixCells>
<TablixCell>
<CellContents>
<Textbox Name="Textbox460">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value />
<Style>
<FontFamily>Tahoma</FontFamily>
</Style>
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Textbox460</rd:DefaultName>
<Style>
<Border>
<Style>None</Style>
</Border>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</CellContents>
</TablixCell>
</TablixCells>
</TablixRow>
<TablixRow>
<Height>0.25in</Height>
<TablixCells>
<TablixCell>
<CellContents>
<Textbox Name="Textbox451">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value />
<Style>
<FontFamily>Tahoma</FontFamily>
</Style>
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Textbox451</rd:DefaultName>
<Style>
<Border>
<Style>None</Style>
</Border>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</CellContents>
</TablixCell>
</TablixCells>
</TablixRow>
<TablixRow>
<Height>0.25in</Height>
<TablixCells>
<TablixCell>
<CellContents>
<Textbox Name="Textbox446">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value />
<Style>
<FontFamily>Tahoma</FontFamily>
</Style>
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Textbox446</rd:DefaultName>
<Style>
<Border>
<Style>None</Style>
</Border>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</CellContents>
</TablixCell>
</TablixCells>
</TablixRow>
<TablixRow>
<Height>0.25in</Height>
<TablixCells>
<TablixCell>
<CellContents>
<Textbox Name="Textbox442">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value />
<Style>
<FontFamily>Tahoma</FontFamily>
</Style>
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Textbox442</rd:DefaultName>
<Style>
<Border>
<Style>None</Style>
</Border>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</CellContents>
</TablixCell>
</TablixCells>
</TablixRow>
<TablixRow>
<Height>0.25in</Height>
<TablixCells>
<TablixCell>
<CellContents>
<Textbox Name="Textbox436">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value />
<Style>
<FontFamily>Tahoma</FontFamily>
</Style>
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Textbox436</rd:DefaultName>
<Style>
<Border>
<Style>None</Style>
</Border>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</CellContents>
</TablixCell>
</TablixCells>
</TablixRow>
<TablixRow>
<Height>0.25in</Height>
<TablixCells>
<TablixCell>
<CellContents>
<Textbox Name="Textbox99">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value />
<Style>
<FontFamily>Tahoma</FontFamily>
</Style>
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Textbox99</rd:DefaultName>
<Style>
<Border>
<Style>None</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>
<Group Name="table1_SOPNUMBEa">
<GroupExpressions>
<GroupExpression>=Fields!SOPNUMBEa.Value</GroupExpression>
</GroupExpressions>
<PageBreak>
<BreakLocation>End</BreakLocation>
</PageBreak>
</Group>
<SortExpressions>
<SortExpression>
<Value>=Fields!SOPNUMBEa.Value</Value>
</SortExpression>
</SortExpressions>
<TablixMembers>
<TablixMember>
<Group Name="table1_Details_Group">
<DataElementName>Detail</DataElementName>
</Group>
<TablixMembers>
<TablixMember />
<TablixMember>
<Visibility>
<Hidden>true</Hidden>
</Visibility>
</TablixMember>
<TablixMember>
<Visibility>
<Hidden>true</Hidden>
</Visibility>
</TablixMember>
<TablixMember>
<Visibility>
<Hidden>true</Hidden>
</Visibility>
</TablixMember>
<TablixMember>
<Visibility>
<Hidden>true</Hidden>
</Visibility>
</TablixMember>
<TablixMember>
<Visibility>
<Hidden>true</Hidden>
</Visibility>
</TablixMember>
<TablixMember>
<Visibility>
<Hidden>true</Hidden>
</Visibility>
</TablixMember>
</TablixMembers>
<DataElementName>Detail_Collection</DataElementName>
<DataElementOutput>Output</DataElementOutput>
<KeepTogether>true</KeepTogether>
</TablixMember>
</TablixMembers>
</TablixMember>
</TablixMembers>
</TablixRowHierarchy>
<DataSetName>DataSet1</DataSetName>
<Top>0.32987cm</Top>
<Left>0.03528cm</Left>
<Height>1.71in</Height>
<Width>4in</Width>
<Style />
</Tablix>
</ReportItems>
<Height>1.83987in</Height>
<Style />
</Body>
<Width>7.42546in</Width>
<Page>
<PageHeight>11.69in</PageHeight>
<PageWidth>8.27in</PageWidth>
<LeftMargin>0.25in</LeftMargin>
<RightMargin>0.25in</RightMargin>
<TopMargin>0.25in</TopMargin>
<BottomMargin>0.25in</BottomMargin>
<Style />
</Page>
<AutoRefresh>0</AutoRefresh>
<DataSources>
<DataSource Name="GPDB_CITYW">
<DataSourceReference>GPDB_CITYW</DataSourceReference>
<rd:SecurityType>None</rd:SecurityType>
<rd:DataSourceID>71845ba6-a656-4115-a595-12b9a4b3017f</rd:DataSourceID>
</DataSource>
</DataSources>
<DataSets>
<DataSet Name="DataSet1">
<Query>
<DataSourceName>GPDB_CITYW</DataSourceName>
<QueryParameters>
<QueryParameter Name="#SOPNo">
<Value>=Parameters!SOPNo.Value</Value>
</QueryParameter>
<QueryParameter Name="#BatchNo">
<Value>=Parameters!BatchNo.Value</Value>
</QueryParameter>
</QueryParameters>
<CommandText>EXEC AllInvoice #SOPNo, #BatchNo</CommandText>
<rd:UseGenericDesigner>true</rd:UseGenericDesigner>
</Query>
<Fields>
<Field Name="ITEMDESC">
<DataField>ITEMDESC</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="SOPNUMBEa">
<DataField>SOPNUMBEa</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
</Fields>
</DataSet>
</DataSets>
<ReportParameters>
<ReportParameter Name="SOPNo">
<DataType>String</DataType>
<AllowBlank>true</AllowBlank>
<Prompt>SOPNo</Prompt>
</ReportParameter>
<ReportParameter Name="BatchNo">
<DataType>String</DataType>
<AllowBlank>true</AllowBlank>
<Prompt>Batch No</Prompt>
</ReportParameter>
</ReportParameters>
<Language>en-US</Language>
<ConsumeContainerWhitespace>true</ConsumeContainerWhitespace>
<rd:ReportUnitType>Inch</rd:ReportUnitType>
<rd:ReportID>3cdad144-fdac-4806-9f36-2841d5131ecd</rd:ReportID>
</Report>
It has to do with the "Group Properties" | "Page Breaks" for the row group named table1_SOPNUMBEa. You'll need to untick the Also at the end of a group checkbox.
Screenshot of "Group Properties" | "Page Breaks"
Here are the example records I used:
SELECT tbl.* FROM (VALUES
( 'A', 1)
, ( 'B', 2)
, ( 'C', 3)
, ( 'D', 4)
, ( 'E', 5)
) tbl ([ITEMDESC], [SOPNUMBEa])
side-note: It's always nice to find another SSRS Developer in Melbourne. :)
Related
I am using HTML tags which has bullets and rendering in a table. Space before and after Bullets is not ok. I tried changing code in CSS but it didnt help. Pls let me know how can we reduce space before and after bullet in an un ordered list.
Try using Wingdings font for the bullet. Lower case "l" is what I use in the example below.
Preview
Design
Report XML .rdl code
<?xml version="1.0" encoding="utf-8"?>
<Report MustUnderstand="df" xmlns="http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner" xmlns:df="http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition/defaultfontfamily">
<df:DefaultFontFamily>Segoe UI</df:DefaultFontFamily>
<AutoRefresh>0</AutoRefresh>
<DataSources>
<DataSource Name="DataSource1">
<DataSourceReference>TempSource</DataSourceReference>
<rd:SecurityType>None</rd:SecurityType>
<rd:DataSourceID>0d516ad5-9001-426b-9cbc-383be6a64511</rd:DataSourceID>
</DataSource>
</DataSources>
<DataSets>
<DataSet Name="DataSet1">
<Query>
<DataSourceName>DataSource1</DataSourceName>
<CommandText>SELECT tbl.* FROM (VALUES
( 'Example 1')
, ( 'Example 2')
, ( 'Example 3')
, ( 'Example 4')
) tbl ([Column1])
</CommandText>
</Query>
<Fields>
<Field Name="Column1">
<DataField>Column1</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
</Fields>
</DataSet>
</DataSets>
<ReportSections>
<ReportSection>
<Body>
<ReportItems>
<Tablix Name="Tablix1">
<TablixBody>
<TablixColumns>
<TablixColumn>
<Width>3.74354cm</Width>
</TablixColumn>
</TablixColumns>
<TablixRows>
<TablixRow>
<Height>0.6cm</Height>
<TablixCells>
<TablixCell>
<CellContents>
<Textbox Name="Textbox1">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>Column1</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="Column1">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value> l </Value>
<Style>
<FontFamily>Wingdings</FontFamily>
<FontSize>8pt</FontSize>
</Style>
</TextRun>
<TextRun>
<Value xml:space="preserve"> </Value>
<Style>
<FontSize>8pt</FontSize>
</Style>
</TextRun>
<TextRun>
<Value>=Fields!Column1.Value</Value>
<Style />
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Column1</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>
<KeepWithGroup>After</KeepWithGroup>
</TablixMember>
<TablixMember>
<Group Name="Details" />
</TablixMember>
</TablixMembers>
</TablixRowHierarchy>
<DataSetName>DataSet1</DataSetName>
<Top>1.16099cm</Top>
<Left>1.92828cm</Left>
<Height>1.2cm</Height>
<Width>3.74354cm</Width>
<Style>
<Border>
<Style>None</Style>
</Border>
</Style>
</Tablix>
</ReportItems>
<Height>2in</Height>
<Style />
</Body>
<Width>6.5in</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>
</ReportSection>
</ReportSections>
<ReportParametersLayout>
<GridLayoutDefinition>
<NumberOfColumns>4</NumberOfColumns>
<NumberOfRows>2</NumberOfRows>
</GridLayoutDefinition>
</ReportParametersLayout>
<rd:ReportUnitType>Cm</rd:ReportUnitType>
<rd:ReportID>7f2c088e-84cc-4a52-954f-bdaa79ef90a1</rd:ReportID>
</Report>
I try to get count for each age category for distinct Cust for each of Provider, and having big problem here. I'm able to get correct CountDistinct Customer Count but can't get right break down for Adult/Senior category. Is it possible you think to implement inside rdl, as I REALLY can't touch existing Dataset which is plain detail like on the right of my pic.
SELECT 'Agent100' ProvID, '1111' CustID, 'Adult' Cat, '2019-1-1' Serv_Date UNION
SELECT 'Agent100' ProvID, '1111' CustID, 'Adult' Cat, '2019-2-2' Serv_Date UNION
SELECT 'Agent100' ProvID, '1111' CustID, 'Adult' Cat, '2019-3-3' Serv_Date UNION
SELECT 'Agent100' ProvID, '222' CustID, 'Senior' Cat, '2019-10-10' Serv_Date UNION
SELECT 'Agent100' ProvID, '333' CustID, 'Adult' Cat, '2019-11-11' Serv_Date UNION
SELECT 'Agent2' ProvID, '555' CustID, 'Adult' Cat, '2019-1-1' Serv_Date
Pasted the whole test rdl too, just change DataSource. Thanks much to all SSRS'ers and SO cure for their nice job !!!
<?xml version="1.0" encoding="utf-8"?>
<Report MustUnderstand="df" xmlns="http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner" xmlns:df="http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition/defaultfontfamily">
<df:DefaultFontFamily>Segoe UI</df:DefaultFontFamily>
<AutoRefresh>0</AutoRefresh>
<DataSources>
<DataSource Name="DataSource1">
<DataSourceReference>YourDataSource</DataSourceReference>
<rd:SecurityType>None</rd:SecurityType>
<rd:DataSourceID>9c15088f-a478-45ea-ad37-a0a289162354</rd:DataSourceID>
</DataSource>
</DataSources>
<DataSets>
<DataSet Name="DataSet1">
<Query>
<DataSourceName>DataSource1</DataSourceName>
<CommandText>SELECT 'Agent100' AS ProvID, '1111' AS CustID, 'Adult' AS Cat, '2019-1-1' AS Serv_Date
UNION
SELECT 'Agent100' AS ProvID, '1111' AS CustID, 'Adult' AS Cat, '2019-2-2' AS Serv_Date
UNION
SELECT 'Agent100' AS ProvID, '1111' AS CustID, 'Adult' AS Cat, '2019-3-3' AS Serv_Date
UNION
SELECT 'Agent100' AS ProvID, '222' AS CustID, 'Senior' AS Cat, '2019-10-10' AS Serv_Date
UNION
SELECT 'Agent100' AS ProvID, '333' AS CustID, 'Adult' AS Cat, '2019-11-11' AS Serv_Date
UNION
SELECT 'Agent2' AS ProvID, '555' AS CustID, 'Adult' AS Cat, '2019-1-1' AS Serv_Date</CommandText>
</Query>
<Fields>
<Field Name="ProvID">
<DataField>ProvID</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="CustID">
<DataField>CustID</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="Cat">
<DataField>Cat</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="Serv_Date">
<DataField>Serv_Date</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
</Fields>
</DataSet>
</DataSets>
<ReportSections>
<ReportSection>
<Body>
<ReportItems>
<Tablix Name="Tablix2">
<TablixBody>
<TablixColumns>
<TablixColumn>
<Width>0.6875in</Width>
</TablixColumn>
</TablixColumns>
<TablixRows>
<TablixRow>
<Height>0.25in</Height>
<TablixCells>
<TablixCell>
<CellContents>
<Textbox Name="Textbox6">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>Cat</Value>
<Style>
<Color>White</Color>
</Style>
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Textbox5</rd:DefaultName>
<Style>
<Border>
<Color>LightGrey</Color>
<Style>Solid</Style>
</Border>
<BackgroundColor>Gray</BackgroundColor>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</CellContents>
</TablixCell>
</TablixCells>
</TablixRow>
<TablixRow>
<Height>0.25in</Height>
<TablixCells>
<TablixCell>
<CellContents>
<Textbox Name="Cat2">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>=Fields!Cat.Value</Value>
<Style />
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Cat</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>
<Visibility>
<Hidden>true</Hidden>
</Visibility>
</TablixMember>
</TablixMembers>
</TablixColumnHierarchy>
<TablixRowHierarchy>
<TablixMembers>
<TablixMember>
<TablixHeader>
<Size>1in</Size>
<CellContents>
<Textbox Name="Textbox19">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>Prov ID</Value>
<Style>
<Color>White</Color>
</Style>
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Textbox19</rd:DefaultName>
<Style>
<Border>
<Color>LightGrey</Color>
<Style>Solid</Style>
</Border>
<BackgroundColor>DarkBlue</BackgroundColor>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</CellContents>
</TablixHeader>
<TablixMembers>
<TablixMember>
<TablixHeader>
<Size>1in</Size>
<CellContents>
<Textbox Name="Textbox35">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>Adult</Value>
<Style>
<Color>White</Color>
</Style>
</TextRun>
</TextRuns>
<Style>
<TextAlign>Center</TextAlign>
</Style>
</Paragraph>
</Paragraphs>
<rd:DefaultName>Textbox35</rd:DefaultName>
<Style>
<Border>
<Color>LightGrey</Color>
<Style>Solid</Style>
</Border>
<BackgroundColor>DarkBlue</BackgroundColor>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</CellContents>
</TablixHeader>
<TablixMembers>
<TablixMember>
<TablixHeader>
<Size>1in</Size>
<CellContents>
<Textbox Name="Textbox33">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>Senior</Value>
<Style>
<Color>White</Color>
</Style>
</TextRun>
</TextRuns>
<Style>
<TextAlign>Center</TextAlign>
</Style>
</Paragraph>
</Paragraphs>
<rd:DefaultName>Textbox33</rd:DefaultName>
<Style>
<Border>
<Color>LightGrey</Color>
<Style>Solid</Style>
</Border>
<BackgroundColor>DarkBlue</BackgroundColor>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</CellContents>
</TablixHeader>
<TablixMembers>
<TablixMember>
<TablixHeader>
<Size>1in</Size>
<CellContents>
<Textbox Name="Textbox37">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>Distinct Cust</Value>
<Style>
<Color>White</Color>
</Style>
</TextRun>
</TextRuns>
<Style>
<TextAlign>Center</TextAlign>
</Style>
</Paragraph>
</Paragraphs>
<rd:DefaultName>Textbox37</rd:DefaultName>
<Style>
<Border>
<Color>LightGrey</Color>
<Style>Solid</Style>
</Border>
<BackgroundColor>DarkBlue</BackgroundColor>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</CellContents>
</TablixHeader>
<TablixMembers>
<TablixMember />
</TablixMembers>
</TablixMember>
</TablixMembers>
</TablixMember>
</TablixMembers>
</TablixMember>
</TablixMembers>
<KeepWithGroup>After</KeepWithGroup>
</TablixMember>
<TablixMember>
<Group Name="ProvID">
<GroupExpressions>
<GroupExpression>=Fields!ProvID.Value</GroupExpression>
</GroupExpressions>
</Group>
<SortExpressions>
<SortExpression>
<Value>=Fields!ProvID.Value</Value>
</SortExpression>
</SortExpressions>
<TablixHeader>
<Size>1in</Size>
<CellContents>
<Textbox Name="ProvID1">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>=Fields!ProvID.Value</Value>
<Style />
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>ProvID1</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>1in</Size>
<CellContents>
<Textbox Name="Textbox36">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>=Sum(Iif(Fields!Cat.Value="Adult",1,0))</Value>
<Style />
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Textbox36</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>1in</Size>
<CellContents>
<Textbox Name="Textbox34">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>=Sum(Iif(Fields!Cat.Value="Senior",1,0))</Value>
<Style />
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Textbox34</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>1in</Size>
<CellContents>
<Textbox Name="Textbox38">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>=CountDistinct(Fields!CustID.Value)</Value>
<Style />
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Textbox38</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>
</TablixMember>
</TablixMembers>
</TablixMember>
</TablixMembers>
</TablixMember>
</TablixMembers>
</TablixRowHierarchy>
<DataSetName>DataSet1</DataSetName>
<Height>0.5in</Height>
<Width>4.6875in</Width>
<Style>
<Border>
<Style>None</Style>
</Border>
</Style>
</Tablix>
</ReportItems>
<Height>0.5in</Height>
<Style />
</Body>
<Width>4.6875in</Width>
<Page>
<LeftMargin>1in</LeftMargin>
<RightMargin>1in</RightMargin>
<TopMargin>1in</TopMargin>
<BottomMargin>1in</BottomMargin>
<Style />
</Page>
</ReportSection>
</ReportSections>
<ReportParametersLayout>
<GridLayoutDefinition>
<NumberOfColumns>4</NumberOfColumns>
<NumberOfRows>2</NumberOfRows>
</GridLayoutDefinition>
</ReportParametersLayout>
<rd:ReportUnitType>Inch</rd:ReportUnitType>
<rd:ReportID>3e0536ce-aa9c-4d8f-afa8-3f0ed263e768</rd:ReportID>
</Report>
You need to use a matrix, not a table. As you already have a good dataset this is easy.
Add a matrix, drag your ProvID to the "rows" placeholder, drag Cat to the "Columns" placeholder.
Them in the "data" placeholder, set the expression to
=CountDistinct(Fields!CustID.Value)
If you need the total in hte third column then right-click the 'Cat' column group in the panel below and select "Add Total => After"
The report design will look like this (left you original for comparison)
When rendered it looks like this...
For that simple case it should work, this is basically can be described as SUMDISTINCT, if you have other columns and want to keep table solution you can add bit logic into DataSet like here
https://www.codeproject.com/Questions/1045429/How-to-get-Distinct-Sum-at-SSRS-Expression
I got a request to change the shape of the legend in one of the report from rectangle to circle shape,
currently report looks like this
but the required shape look like this
I checked the properties of the legend but there is no way I found to change the shape or use image.
Any idea how can achieve that?
thanks
I was able to do this with a matrix. First you have to insert a rectangle in the cell you want to use for the legend. Then the assign the background color of the rectangle to the column in an expression e.g. =Fields!ColorHex.Value. Next insert the circle image over top of the rectangle.
You should be able to use the same dataset for the matrix (legend) as you do for the chart. You'll need to add a column for the ColorHex values to your dataset. Then you can also reference the same column in the chart for the colors.
Report Preview:
Circle .png file with transparency:
I created the image using GIMP (GNU Image Manipulation Program)
Example SQL for color hex codes
SELECT tbl.* FROM (VALUES
( '#90EE90', 'Due next month')
, ( '#FAFAD2', 'Due this month')
, ( '#FFB6C1', 'Overdue')
) tbl ([ColorHex], [GroupType])
Example XML for the .rdl report:
<?xml version="1.0" encoding="utf-8"?>
<Report MustUnderstand="df" xmlns="http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner" xmlns:df="http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition/defaultfontfamily">
<df:DefaultFontFamily>Segoe UI</df:DefaultFontFamily>
<AutoRefresh>0</AutoRefresh>
<DataSources>
<DataSource Name="YourDataSource">
<DataSourceReference>YourDataSource</DataSourceReference>
<rd:SecurityType>None</rd:SecurityType>
<rd:DataSourceID>68eb8e17-19b1-4ab3-8315-91c1cb31c63a</rd:DataSourceID>
</DataSource>
</DataSources>
<DataSets>
<DataSet Name="DataSet1">
<Query>
<DataSourceName>YourDataSource</DataSourceName>
<CommandText>SELECT tbl.* FROM (VALUES
( '#90EE90', 'Due next month')
, ( '#FAFAD2', 'Due this month')
, ( '#FFB6C1', 'Overdue')
) tbl ([ColorHex], [GroupType]) </CommandText>
</Query>
<Fields>
<Field Name="ColorHex">
<DataField>ColorHex</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="GroupType">
<DataField>GroupType</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
</Fields>
</DataSet>
</DataSets>
<ReportSections>
<ReportSection>
<Body>
<ReportItems>
<Tablix Name="Tablix3">
<TablixBody>
<TablixColumns>
<TablixColumn>
<Width>0.9125cm</Width>
</TablixColumn>
<TablixColumn>
<Width>3.21438cm</Width>
</TablixColumn>
</TablixColumns>
<TablixRows>
<TablixRow>
<Height>0.89146cm</Height>
<TablixCells>
<TablixCell>
<CellContents>
<Rectangle Name="Rectangle3">
<ReportItems>
<Image Name="Image3">
<Source>Embedded</Source>
<Value>legend_template</Value>
<Sizing>FitProportional</Sizing>
<Height>0.89146cm</Height>
<Width>0.9125cm</Width>
<Style>
<Border>
<Style>None</Style>
</Border>
</Style>
</Image>
</ReportItems>
<KeepTogether>true</KeepTogether>
<Style>
<Border>
<Style>None</Style>
</Border>
<RightBorder>
<Color>White</Color>
<Style>Solid</Style>
</RightBorder>
<BackgroundColor>=Fields!ColorHex.Value</BackgroundColor>
</Style>
</Rectangle>
</CellContents>
</TablixCell>
<TablixCell>
<CellContents>
<Textbox Name="GroupType1">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>=Fields!GroupType.Value</Value>
<Style>
<FontFamily>Calibri</FontFamily>
</Style>
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>GroupType1</rd:DefaultName>
<Style>
<Border>
<Color>LightGrey</Color>
<Style>None</Style>
</Border>
<VerticalAlign>Middle</VerticalAlign>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</CellContents>
</TablixCell>
</TablixCells>
</TablixRow>
</TablixRows>
</TablixBody>
<TablixColumnHierarchy>
<TablixMembers>
<TablixMember>
<Group Name="GroupType">
<GroupExpressions>
<GroupExpression>=Fields!GroupType.Value</GroupExpression>
</GroupExpressions>
</Group>
<SortExpressions>
<SortExpression>
<Value>=Fields!GroupType.Value</Value>
</SortExpression>
</SortExpressions>
<TablixMembers>
<TablixMember />
<TablixMember />
</TablixMembers>
</TablixMember>
</TablixMembers>
</TablixColumnHierarchy>
<TablixRowHierarchy>
<TablixMembers>
<TablixMember>
<Group Name="RowGroup">
<GroupExpressions>
<GroupExpression />
</GroupExpressions>
</Group>
<TablixHeader>
<Size>0.07938cm</Size>
<CellContents>
<Textbox Name="Textbox9">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value />
<Style />
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Textbox9</rd:DefaultName>
<Style>
<Border>
<Color>LightGrey</Color>
<Style>None</Style>
</Border>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</CellContents>
</TablixHeader>
</TablixMember>
</TablixMembers>
</TablixRowHierarchy>
<DataSetName>DataSet1</DataSetName>
<Height>0.89146cm</Height>
<Width>4.20625cm</Width>
<Style>
<Border>
<Style>None</Style>
</Border>
</Style>
</Tablix>
</ReportItems>
<Height>0.35097in</Height>
<Style />
</Body>
<Width>1.656in</Width>
<Page>
<PageHeight>21cm</PageHeight>
<PageWidth>29.7cm</PageWidth>
<LeftMargin>0.75cm</LeftMargin>
<RightMargin>0.75cm</RightMargin>
<TopMargin>0.75cm</TopMargin>
<BottomMargin>0.75cm</BottomMargin>
<ColumnSpacing>0.13cm</ColumnSpacing>
<Style />
</Page>
</ReportSection>
</ReportSections>
<ReportParametersLayout>
<GridLayoutDefinition>
<NumberOfColumns>2</NumberOfColumns>
<NumberOfRows>4</NumberOfRows>
</GridLayoutDefinition>
</ReportParametersLayout>
<EmbeddedImages>
<EmbeddedImage Name="legend_template">
<MIMEType>image/png</MIMEType>
<ImageData>iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAYAAADimHc4AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsSAAALEgHS3X78AAAAB3RJTUUH4goXAjEeL/CJEQAAAZNJREFUeNrt3dFxwzAMg2GL1/1Xdh6yQNujSNH+MEBD4hfg+nqN1n3f90VtChYAAAABAAABAADV6+fk4dZaK+PnnPyus04aLsvwSUDaAVSZfiqMNgDdxp8CohzAacZ3gwjm985YkoAJxnelIZjfO/u2BEw2vjINwfzenYL5vbsF83t3DOb37hrM7905mN+7u78HNCuc/t4UBPN7IaigiRXk9Od5EszvhaCCJlWQ05/vkQRMSYDTvycFEjD5TZiKAKiffTUkASoIADoZgP7f+xyQABUEAAEAAAEAAAEAAAEAAAEAAAEAAAEAAHUD8MWu/9dvvJMAFQQAnQ7Ac2BP/0uACqLIjhT9zSsJmFRBUpDvkQRMewhLQa43UfVBzFdBz3oPkIIcL6Lrg5mvgmZXkBTk7B6nDPJG81Mr6E0QMneNUwd7g/lbHsJPhrBjt5gy6BPNv66CGzSm/6P3bn9i+gLTZy+9RWlKGio9iacuNmVGF7k1Hw5XGb71KsNOGC7zLAbiOls647cgAgAAAgAAAgAA+uoD75Psfe3m0nIAAAAASUVORK5CYII=</ImageData>
</EmbeddedImage>
</EmbeddedImages>
<rd:ReportUnitType>Cm</rd:ReportUnitType>
<rd:ReportID>6203a576-d7cc-4b57-9a9b-12cf325d6203</rd:ReportID>
</Report>
Is it possible to perform that calculation in rdl directly to get that difference which comes from row + column group column?
Please refer to my previous post for sample data if needed. Previous post details click here
I'd like to compute that value in F2,3,4 column.
Thanks for all help.
M
This is selfcontained rdl, just put your server name.
<?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">
<TablixCorner>
<TablixCornerRows>
<TablixCornerRow>
<TablixCornerCell>
<CellContents>
<Textbox Name="Textbox4">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>Region</Value>
<Style />
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Textbox4</rd:DefaultName>
<Style>
<Border>
<Color>LightGrey</Color>
<Style>Solid</Style>
</Border>
<BackgroundColor>LimeGreen</BackgroundColor>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</CellContents>
</TablixCornerCell>
</TablixCornerRow>
</TablixCornerRows>
</TablixCorner>
<TablixBody>
<TablixColumns>
<TablixColumn>
<Width>1in</Width>
</TablixColumn>
<TablixColumn>
<Width>1in</Width>
</TablixColumn>
<TablixColumn>
<Width>1in</Width>
</TablixColumn>
</TablixColumns>
<TablixRows>
<TablixRow>
<Height>0.25in</Height>
<TablixCells>
<TablixCell>
<CellContents>
<Textbox Name="Textbox3">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>=count("1")</Value>
<Style />
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Textbox3</rd:DefaultName>
<Style>
<Border>
<Color>LightGrey</Color>
<Style>Solid</Style>
</Border>
<LeftBorder>
<Color>Black</Color>
<Style>Solid</Style>
<Width>1pt</Width>
</LeftBorder>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</CellContents>
</TablixCell>
<TablixCell>
<CellContents>
<Textbox Name="Textbox6">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>=count("1")/count("1","YEAR")</Value>
<Style>
<Format>0.00%</Format>
</Style>
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Textbox6</rd:DefaultName>
<Style>
<Border>
<Color>LightGrey</Color>
<Style>Solid</Style>
</Border>
<RightBorder>
<Color>Black</Color>
<Style>Solid</Style>
<Width>1pt</Width>
</RightBorder>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</CellContents>
</TablixCell>
<TablixCell>
<CellContents>
<Textbox Name="Textbox14">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>=IIF(count("1") = 3,"40-14=26%","?")</Value>
<Style />
</TextRun>
</TextRuns>
<Style>
<TextAlign>Center</TextAlign>
</Style>
</Paragraph>
</Paragraphs>
<rd:DefaultName>Textbox14</rd:DefaultName>
<Style>
<Border>
<Color>LightGrey</Color>
<Style>Solid</Style>
</Border>
<BackgroundColor>Yellow</BackgroundColor>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</CellContents>
</TablixCell>
</TablixCells>
</TablixRow>
<TablixRow>
<Height>0.25in</Height>
<TablixCells>
<TablixCell>
<CellContents>
<Textbox Name="Textbox8">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>=count("1")</Value>
<Style>
<FontWeight>Bold</FontWeight>
</Style>
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Textbox8</rd:DefaultName>
<Style>
<Border>
<Color>LightGrey</Color>
<Style>Solid</Style>
</Border>
<TopBorder>
<Color>Black</Color>
<Style>Solid</Style>
<Width>1pt</Width>
</TopBorder>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</CellContents>
</TablixCell>
<TablixCell>
<CellContents>
<Textbox Name="Textbox9">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value />
<Style>
<FontWeight>Bold</FontWeight>
</Style>
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Textbox9</rd:DefaultName>
<Style>
<Border>
<Color>LightGrey</Color>
<Style>Solid</Style>
</Border>
<TopBorder>
<Color>Black</Color>
<Style>Solid</Style>
<Width>1pt</Width>
</TopBorder>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</CellContents>
</TablixCell>
<TablixCell>
<CellContents>
<Textbox Name="Textbox15">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value />
<Style>
<FontWeight>Bold</FontWeight>
</Style>
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Textbox15</rd:DefaultName>
<Style>
<Border>
<Color>LightGrey</Color>
<Style>Solid</Style>
</Border>
<TopBorder>
<Color>Black</Color>
<Style>Solid</Style>
<Width>1pt</Width>
</TopBorder>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</CellContents>
</TablixCell>
</TablixCells>
</TablixRow>
</TablixRows>
</TablixBody>
<TablixColumnHierarchy>
<TablixMembers>
<TablixMember>
<Group Name="YEAR">
<GroupExpressions>
<GroupExpression>=Fields!YEAR.Value</GroupExpression>
</GroupExpressions>
</Group>
<TablixHeader>
<Size>0.25in</Size>
<CellContents>
<Textbox Name="Textbox2">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>=Fields!YEAR.Value</Value>
<Style>
<FontWeight>Bold</FontWeight>
</Style>
</TextRun>
</TextRuns>
<Style>
<TextAlign>Center</TextAlign>
</Style>
</Paragraph>
</Paragraphs>
<rd:DefaultName>Textbox2</rd:DefaultName>
<Style>
<Border>
<Color>LightGrey</Color>
<Style>Solid</Style>
</Border>
<BackgroundColor>LimeGreen</BackgroundColor>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</CellContents>
</TablixHeader>
<TablixMembers>
<TablixMember />
<TablixMember />
</TablixMembers>
</TablixMember>
<TablixMember>
<TablixHeader>
<Size>0.25in</Size>
<CellContents>
<Textbox Name="Textbox13">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>Difference</Value>
<Style />
</TextRun>
</TextRuns>
<Style>
<TextAlign>Center</TextAlign>
</Style>
</Paragraph>
</Paragraphs>
<rd:DefaultName>Textbox13</rd:DefaultName>
<Style>
<Border>
<Color>LightGrey</Color>
<Style>Solid</Style>
</Border>
<BackgroundColor>Yellow</BackgroundColor>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</CellContents>
</TablixHeader>
</TablixMember>
</TablixMembers>
</TablixColumnHierarchy>
<TablixRowHierarchy>
<TablixMembers>
<TablixMember>
<Group Name="Region">
<GroupExpressions>
<GroupExpression>=Fields!Region.Value</GroupExpression>
</GroupExpressions>
</Group>
<SortExpressions>
<SortExpression>
<Value>=Fields!Region.Value</Value>
</SortExpression>
</SortExpressions>
<TablixHeader>
<Size>1in</Size>
<CellContents>
<Textbox Name="Region">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>=Fields!Region.Value</Value>
<Style />
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Region</rd:DefaultName>
<Style>
<Border>
<Color>LightGrey</Color>
<Style>Solid</Style>
</Border>
<RightBorder>
<Color>Black</Color>
<Style>Solid</Style>
<Width>1pt</Width>
</RightBorder>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</CellContents>
</TablixHeader>
</TablixMember>
<TablixMember>
<TablixHeader>
<Size>1in</Size>
<CellContents>
<Textbox Name="Textbox7">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>Total</Value>
<Style>
<FontWeight>Bold</FontWeight>
</Style>
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Textbox7</rd:DefaultName>
<Style>
<Border>
<Color>LightGrey</Color>
<Style>Solid</Style>
</Border>
<TopBorder>
<Color>Black</Color>
<Style>Solid</Style>
<Width>1pt</Width>
</TopBorder>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</CellContents>
</TablixHeader>
<KeepWithGroup>Before</KeepWithGroup>
</TablixMember>
</TablixMembers>
</TablixRowHierarchy>
<DataSetName>DataSet1</DataSetName>
<Height>0.75in</Height>
<Width>4in</Width>
<Style>
<Border>
<Style>None</Style>
</Border>
</Style>
</Tablix>
</ReportItems>
<Height>0.76042in</Height>
<Style />
</Body>
<Width>4in</Width>
<Page>
<LeftMargin>1in</LeftMargin>
<RightMargin>1in</RightMargin>
<TopMargin>1in</TopMargin>
<BottomMargin>1in</BottomMargin>
<Style />
</Page>
<AutoRefresh>0</AutoRefresh>
<DataSources>
<DataSource Name="DataSource1">
<ConnectionProperties>
<DataProvider>SQL</DataProvider>
<ConnectString>Data Source=dwvm;Initial Catalog=master</ConnectString>
<IntegratedSecurity>true</IntegratedSecurity>
</ConnectionProperties>
<rd:SecurityType>Integrated</rd:SecurityType>
<rd:DataSourceID>02a410c1-7691-4044-b48e-1c2cfd1ac685</rd:DataSourceID>
</DataSource>
</DataSources>
<DataSets>
<DataSet Name="DataSet1">
<Query>
<DataSourceName>DataSource1</DataSourceName>
<CommandText>WITH cte AS (SELECT 'Asia' AS Region, 2012 AS YEAR, 'Wo' AS Cust
UNION ALL
SELECT 'Asia' AS Region, 2012 AS YEAR, 'Ma' AS Cust
UNION ALL
SELECT 'Asia' AS Region, 2013 AS YEAR, 'Li' AS Cust
UNION ALL
SELECT 'Asia' AS Region, 2013 AS YEAR, 'Xo' AS Cust
UNION ALL
SELECT 'Asia' AS Region, 2013 AS YEAR, 'Xo' AS Cust
UNION ALL
SELECT 'Africa' AS Region, 2012 AS YEAR, 'Cora' AS Cust
UNION ALL
SELECT 'Africa' AS Region, 2012 AS YEAR, 'Lamy' AS Cust
UNION ALL
SELECT 'Africa' AS Region, 2013 AS YEAR, 'Kary' AS Cust
UNION ALL
SELECT 'US' AS Region, 2013 AS YEAR, 'Michael' AS Cust
UNION ALL
SELECT 'US' AS Region, 2013 AS YEAR, 'Rachelle' AS Cust
UNION ALL
SELECT 'US' AS Region, 2013 AS YEAR, 'Rafael' AS Cust
UNION ALL
SELECT 'US' AS Region, 2013 AS YEAR, 'Minace' AS Cust
UNION ALL
SELECT 'US' AS Region, 2012 AS YEAR, 'Landley' AS Cust)
SELECT Region, YEAR, Cust
FROM cte AS cte_1</CommandText>
</Query>
<Fields>
<Field Name="Region">
<DataField>Region</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="YEAR">
<DataField>YEAR</DataField>
<rd:TypeName>System.Int32</rd:TypeName>
</Field>
<Field Name="Cust">
<DataField>Cust</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
</Fields>
</DataSet>
</DataSets>
<rd:ReportUnitType>Inch</rd:ReportUnitType>
<rd:ReportID>3d834541-c3dc-4dd5-86f6-007dea45a763</rd:ReportID>
</Report>
I want to style the legend items of the WinRT XAML Toolkit Chart Control.
I checked the source code and found the following style:
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:datavis="using:WinRTXamlToolkit.Controls.DataVisualization">
<Style
TargetType="datavis:Legend">
<Setter
Property="BorderBrush"
Value="Black" />
<Setter
Property="BorderThickness"
Value="1" />
<Setter
Property="IsTabStop"
Value="False" />
<Setter
Property="TitleStyle">
<Setter.Value>
<Style
TargetType="datavis:Title">
<Setter
Property="Margin"
Value="0,5,0,10" />
<Setter
Property="FontWeight"
Value="Bold" />
<Setter
Property="HorizontalAlignment"
Value="Center" />
</Style>
</Setter.Value>
</Setter>
<Setter
Property="Template">
<Setter.Value>
<ControlTemplate
TargetType="datavis:Legend">
<Border
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Padding="2">
<Grid>
<Grid.RowDefinitions>
<RowDefinition
Height="Auto" />
<RowDefinition />
</Grid.RowDefinitions>
<datavis:Title
Grid.Row="0"
x:Name="HeaderContent"
Content="{TemplateBinding Header}"
ContentTemplate="{TemplateBinding HeaderTemplate}"
Style="{TemplateBinding TitleStyle}" />
<ScrollViewer
Grid.Row="1"
VerticalScrollBarVisibility="Auto"
BorderThickness="0"
Padding="0"
IsTabStop="False">
<ItemsPresenter
x:Name="Items"
Margin="10,0,10,10" />
</ScrollViewer>
</Grid>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
but this styles the Legend container and Title only.
how can I style the legend items ??
EDIT:
Thanks a lot Filip for the answer, this is exactly what I wanted.
but Visual Studio gave me an error at:
<Setter.Value>
<ItemsPanelTemplate>
<controls:UniformGrid
Columns="1"
Rows="5" />
</ItemsPanelTemplate>
</Setter.Value>
it said the controls:UniformGrid was not found, I removed this section and managed to get things working.
A thing to note first is that the Legend control is an ItemsControl, so you can style its items using ItemContainerStyle. An item template is governed by LegendItem style which you can find in the source too. The way to style it all in an application is to set the Style of the Legend by setting the LegendStyle property on the Chart control. Then in the Legend style set ItemContainerStyle to a Style of LegendItem. I haven't checked if the Chart control behaves correctly in Blend, but that would be the best place to edit these if it does. I just handcrafted this sample.
<charting:Chart
x:Name="PieChart"
Title="Pie Chart"
Margin="70,0">
<charting:Chart.Series>
<Series:PieSeries
Title="Population"
ItemsSource="{Binding Items}"
IndependentValueBinding="{Binding Name}"
DependentValueBinding="{Binding Value}"
IsSelectionEnabled="True" />
</charting:Chart.Series>
<charting:Chart.LegendStyle>
<Style
TargetType="datavis:Legend">
<Setter
Property="VerticalAlignment"
Value="Stretch" />
<Setter
Property="Background"
Value="#444" />
<Setter
Property="ItemsPanel">
<Setter.Value>
<ItemsPanelTemplate>
<controls:UniformGrid
Columns="1"
Rows="5" />
</ItemsPanelTemplate>
</Setter.Value>
</Setter>
<Setter
Property="TitleStyle">
<Setter.Value>
<Style
TargetType="datavis:Title">
<Setter
Property="Margin"
Value="0,5,0,10" />
<Setter
Property="FontWeight"
Value="Bold" />
<Setter
Property="HorizontalAlignment"
Value="Center" />
</Style>
</Setter.Value>
</Setter>
<Setter
Property="ItemContainerStyle"
xmlns:series="using:WinRTXamlToolkit.Controls.DataVisualization.Charting">
<Setter.Value>
<Style
TargetType="series:LegendItem">
<Setter
Property="Template">
<Setter.Value>
<ControlTemplate
TargetType="series:LegendItem">
<Border
MinWidth="200"
Margin="20,10"
CornerRadius="10"
VerticalAlignment="Stretch"
HorizontalAlignment="Stretch"
Background="{Binding Background}">
<datavis:Title
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="24"
FontWeight="Bold"
Content="{TemplateBinding Content}" />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Setter.Value>
</Setter>
<Setter
Property="Template">
<Setter.Value>
<ControlTemplate
TargetType="datavis:Legend">
<Border
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Padding="2">
<Grid>
<Grid.RowDefinitions>
<RowDefinition
Height="Auto" />
<RowDefinition />
</Grid.RowDefinitions>
<datavis:Title
Grid.Row="0"
x:Name="HeaderContent"
Content="{TemplateBinding Header}"
ContentTemplate="{TemplateBinding HeaderTemplate}"
Style="{TemplateBinding TitleStyle}" />
<ScrollViewer
Grid.Row="1"
VerticalScrollBarVisibility="Auto"
BorderThickness="0"
Padding="0"
IsTabStop="False">
<ItemsPresenter
x:Name="Items"
Margin="10,0,10,10" />
</ScrollViewer>
</Grid>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</charting:Chart.LegendStyle>
</charting:Chart>