Showing posts with label avg. Show all posts
Showing posts with label avg. Show all posts

Monday, March 19, 2012

Interesting Average problem

I have a table that has a numeric field and the footer of the field has to
display the AVG of the field.
Some of the field values are null, and those should be left out of the
calculation.
Doing a AVG(Field!Name.Value) of course take them into account as well.
Any ideas?
Thanks.Shrink, shrink, shrink, in the end it works if the field is null, different
story if it is zero.
"Chris Botha" <chris_s_botha@.AT_h.o.t.m.a.i.l.com> wrote in message
news:ujqmWjUZEHA.1480@.TK2MSFTNGP10.phx.gbl...
> I have a table that has a numeric field and the footer of the field has to
> display the AVG of the field.
> Some of the field values are null, and those should be left out of the
> calculation.
> Doing a AVG(Field!Name.Value) of course take them into account as well.
> Any ideas?
> Thanks.
>

Monday, March 12, 2012

Interactive sort in matrix not working on 9.00.3054.00

I'm having problem with sorting in matrix. My report looks something like below.

Name* Avg.* | Test1 Test2 Test3

==============================================

Jim 50% | 100% 40% 10%

John 28% | 5% 40% 40%

The column with * need to be sorted. I can sort the name and average fine in Microsoft SQL Server Reporting Services Version 9.00.2047.00. BUt when I run this in another environment, sorting on Avg doesn't work. The version on that is Microsoft SQL Server Reporting Services Version 9.00.3054.00.

I put together a sample code against the northwinddatabase. Sorting works in 9.00.2047.00 but not 9.00.3054.00. Any ideas?

<?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="DataSource11">

<DataSourceReference>DataSource1</DataSourceReference>

<rdataSourceID>632d2cbd-3d9c-44fe-97ac-fbdef687ef47</rdataSourceID>

</DataSource>

</DataSources>

<BottomMargin>0.25in</BottomMargin>

<RightMargin>0.25in</RightMargin>

<PageWidth>11in</PageWidth>

<ReportParameters>

<ReportParameter Name="objecttype">

<DataType>String</DataType>

<DefaultValue>

<Values>

<Value>Student</Value>

</Values>

</DefaultValue>

<AllowBlank>true</AllowBlank>

<Prompt>Object Type</Prompt>

</ReportParameter>

<ReportParameter Name="testid">

<DataType>Integer</DataType>

<DefaultValue>

<Values>

<Value>481</Value>

</Values>

</DefaultValue>

<AllowBlank>true</AllowBlank>

<Prompt>testid</Prompt>

</ReportParameter>

<ReportParameter Name="groupby">

<DataType>String</DataType>

<DefaultValue>

<Values>

<Value>Element</Value>

</Values>

</DefaultValue>

<AllowBlank>true</AllowBlank>

<Prompt>groupby</Prompt>

</ReportParameter>

<ReportParameter Name="usertestdoc">

<DataType>String</DataType>

<DefaultValue>

<Values>

<Value>6453bybbyq</Value>

</Values>

</DefaultValue>

<Prompt>usertestdoc</Prompt>

</ReportParameter>

<ReportParameter Name="dbserver">

<DataType>String</DataType>

<DefaultValue>

<Values>

<Value>Data Source=10.88.22.00;Initial Catalog=xxx;User ID=sa;Password=xxxxx</Value>

</Values>

</DefaultValue>

<AllowBlank>true</AllowBlank>

<Prompt>dbserver</Prompt>

</ReportParameter>

<ReportParameter Name="copyright">

<DataType>String</DataType>

<Nullable>true</Nullable>

<DefaultValue>

<Values>

<Value>Copyright 2007 </Value>

</Values>

</DefaultValue>

<AllowBlank>true</AllowBlank>

<Prompt>copyright</Prompt>

</ReportParameter>

<ReportParameter Name="levelby">

<DataType>String</DataType>

<DefaultValue>

<Values>

<Value>Teacher</Value>

</Values>

</DefaultValue>

<AllowBlank>true</AllowBlank>

<Prompt>levelby</Prompt>

</ReportParameter>

<ReportParameter Name="objectid">

<DataType>Integer</DataType>

<DefaultValue>

<Values>

<Value>0</Value>

</Values>

</DefaultValue>

<AllowBlank>true</AllowBlank>

<Prompt>objectid</Prompt>

</ReportParameter>

</ReportParameters>

<rdrawGrid>true</rdrawGrid>

<InteractiveWidth>8.5in</InteractiveWidth>

<rd:GridSpacing>0.0625in</rd:GridSpacing>

<rdnapToGrid>true</rdnapToGrid>

<Body>

<ReportItems>

<Matrix Name="matrix1">

<MatrixColumns>

<MatrixColumn>

<Width>1.73189in</Width>

</MatrixColumn>

</MatrixColumns>

<Left>0.5in</Left>

<RowGroupings>

<RowGrouping>

<Width>2.3125in</Width>

<DynamicRows>

<ReportItems>

<Textbox Name="shipcountry_1">

<rdefaultName>shipcountry_1</rdefaultName>

<ZIndex>1</ZIndex>

<Style>

<BorderStyle>

<Default>Solid</Default>

</BorderStyle>

<TextAlign>Left</TextAlign>

<PaddingLeft>2pt</PaddingLeft>

<PaddingBottom>2pt</PaddingBottom>

<BackgroundColor>Gainsboro</BackgroundColor>

<PaddingRight>2pt</PaddingRight>

<PaddingTop>2pt</PaddingTop>

</Style>

<CanGrow>true</CanGrow>

<Value>=count(Fields!orderid.value)</Value>

</Textbox>

</ReportItems>

<Grouping Name="matrix1_RowGroup1">

<GroupExpressions>

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

</GroupExpressions>

</Grouping>

</DynamicRows>

</RowGrouping>

</RowGroupings>

<ColumnGroupings>

<ColumnGrouping>

<DynamicColumns>

<ReportItems>

<Textbox Name="customerid">

<rdefaultName>customerid</rdefaultName>

<ZIndex>2</ZIndex>

<Style>

<BorderStyle>

<Default>Solid</Default>

</BorderStyle>

<TextAlign>Center</TextAlign>

<PaddingLeft>2pt</PaddingLeft>

<PaddingBottom>2pt</PaddingBottom>

<BackgroundColor>Gainsboro</BackgroundColor>

<PaddingRight>2pt</PaddingRight>

<PaddingTop>2pt</PaddingTop>

</Style>

<CanGrow>true</CanGrow>

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

</Textbox>

</ReportItems>

<Grouping Name="matrix1_shipcountry">

<GroupExpressions>

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

</GroupExpressions>

</Grouping>

</DynamicColumns>

<Height>0.4375in</Height>

</ColumnGrouping>

</ColumnGroupings>

<DataSetName>dataset</DataSetName>

<Top>0.625in</Top>

<Width>4.04439in</Width>

<Corner>

<ReportItems>

<Rectangle Name="rectangle1">

<ReportItems>

<Textbox Name="textbox1">

<Left>0.0625in</Left>

<Top>0.1875in</Top>

<rdefaultName>textbox1</rdefaultName>

<Width>1in</Width>

<Style>

<PaddingLeft>2pt</PaddingLeft>

<PaddingBottom>2pt</PaddingBottom>

<PaddingRight>2pt</PaddingRight>

<PaddingTop>2pt</PaddingTop>

</Style>

<CanGrow>true</CanGrow>

<UserSort>

<SortExpression>=count(Fields!orderid.Value)</SortExpression>

<SortExpressionScope>matrix1_RowGroup1</SortExpressionScope>

</UserSort>

<Value>SORTME</Value>

</Textbox>

</ReportItems>

<ZIndex>3</ZIndex>

</Rectangle>

</ReportItems>

</Corner>

<Height>0.88597in</Height>

<MatrixRows>

<MatrixRow>

<Height>0.44847in</Height>

<MatrixCells>

<MatrixCell>

<ReportItems>

<Textbox Name="textbox4">

<rdefaultName>textbox4</rdefaultName>

<Style>

<BorderStyle>

<Default>Solid</Default>

</BorderStyle>

<TextAlign>Center</TextAlign>

<PaddingLeft>2pt</PaddingLeft>

<PaddingBottom>2pt</PaddingBottom>

<PaddingRight>2pt</PaddingRight>

<PaddingTop>2pt</PaddingTop>

</Style>

<CanGrow>true</CanGrow>

<Value>=count(Fields!orderid.Value)</Value>

</Textbox>

</ReportItems>

</MatrixCell>

</MatrixCells>

</MatrixRow>

</MatrixRows>

</Matrix>

</ReportItems>

<Height>2.5625in</Height>

</Body>

<rd:ReportID>98ed88ab-a457-4446-8b4c-ff275e2b5e03</rd:ReportID>

<LeftMargin>0.25in</LeftMargin>

<DataSets>

<DataSet Name="dataset">

<Query>

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

<CommandText>select top 30 shipcountry, customerid, orderid from orders</CommandText>

<DataSourceName>DataSource11</DataSourceName>

</Query>

<Fields>

<Field Name="shipcountry">

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

<DataField>shipcountry</DataField>

</Field>

<Field Name="customerid">

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

<DataField>customerid</DataField>

</Field>

<Field Name="orderid">

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

<DataField>orderid</DataField>

</Field>

</Fields>

</DataSet>

</DataSets>

<Code />

<Width>10.3125in</Width>

<InteractiveHeight>11in</InteractiveHeight>

<Language>en-US</Language>

<PageFooter>

<Height>0.1875in</Height>

<PrintOnLastPage>true</PrintOnLastPage>

<PrintOnFirstPage>true</PrintOnFirstPage>

</PageFooter>

<TopMargin>0.25in</TopMargin>

<PageHeight>8.5in</PageHeight>

</Report>


I ran into the same problem a while back but we ended up rebuilding our reports to use tables. I'm kinda curious as to what caused this issue and if anyone ever found a fix.|||

You know it looks like they changed it so that it won't sort based on an aggregate. For example prior to the SP update

I could have a report like this

SortBox Year

Carrier Sum(Passengers)

sort expression Sum(Passengers)

sort expression scope Carrier

Now that still sucks because you can't sort on the Passengers for a given year but at least it sorts on total pax....

Now after the SP(and I checked this in VS05 9.00.3054,VS08 beta 2 RDLC, and Katmai Designer) only non aggregate fields work

sort expression Fields!Carrier, or Fields!Passengers

sort expression scope Carrier

The tablix in Katmai allows you to put something like this together

Year

(Label with sort Passengers)

Carrier Sum(Passengers)

The sort label:

sort expression Fields!Passengers or Sum(Passengers)

sort expression scope Carrier

I'm hopeful that the fact that it doesn't give me an error indicates that this excel type sort will work in the future.

In anycase one possible bypass for the .3054 change appears to be embedding a table in the matrix cell which allows you to sort the "row group" relative to that specific column group. While this doesn't work across all the columns, in some situations it might help out.