Wednesday, March 21, 2012
GroupExpressions and Aggregate()
own calculation of subtotals for matrices and lists, and this works just fine as long as there is only one
<GroupExpression> tag within each <GroupExpressions> tag, e.g.:
<MatrixRows>
<RowGroupings>
<RowGrouping>
<DynamicRows>
<Grouping>
<GroupExpressions>
<GroupExpression>=Fields!Year.Value</GroupExpression>
</GroupExpressions>
</Grouping>
<ReportItems><Textbox><Value>=Fields!Year.Value</Value></Textbox></ReportItems>
</DynamicRows>
</RowGrouping>
<RowGrouping>
<DynamicRows>
<Grouping>
<GroupExpressions><GroupExpression>=Fields!Quarter.Value</GroupExpression></GroupExpressions>
</Grouping>
<ReportItems><Textbox><Value>=Fields!Quarter.Value</Value></Textbox></ReportItems>
</DynamicRows>
</RowGrouping>
<RowGrouping>
<DynamicRows>
<Grouping>
<GroupExpressions><GroupExpression>=Fields!Month.Value</GroupExpression></GroupExpressions>
</Grouping>
<ReportItems><Textbox><Value>=Fields!Month.Value</Value></Textbox></ReportItems>
</DynamicRows>
</RowGrouping>
</RowGroupings>
<MatrixRows>
But when I don't want to show an intermediate grouping, like Quarter in the above, but still want to group by it, the
matrix cells are blank:
<MatrixRows>
<RowGroupings>
<RowGrouping>
<DynamicRows>
<Grouping>
<GroupExpressions>
<GroupExpression>=Fields!Year.Value</GroupExpression>
</GroupExpressions>
</Grouping>
<ReportItems><Textbox><Value>=Fields!Year.Value</Value></Textbox></ReportItems>
</DynamicRows>
</RowGrouping>
<RowGrouping>
<DynamicRows>
<Grouping>
<GroupExpressions>
<GroupExpression>=Fields!Quarter.Value</GroupExpression>
<GroupExpression>=Fields!Month.Value</GroupExpression>
</GroupExpressions>
</Grouping>
<ReportItems><Textbox><Value>=Fields!Month.Value</Value></Textbox></ReportItems>
</DynamicRows>
</RowGrouping>
</RowGroupings>
<MatrixRows>
The dataset is identical, and returns the same results for IsAggregateRow etc.
Can someone please tell me what I'm doing wrong or misunderstanding?
Thanks!
--
Posted using Wimdows.net NntpNews Component -
Post Made from http://www.SqlJunkies.com/newsgroups Our newsgroup engine supports Post Alerts, Ratings, and Searching.Currently this is by design. Aggregate function only works when there is
only one group expression and it must be simple field reference.
Fang Wang (MSFT)
Microsoft SQL Server Reporting Services
This posting is provided "AS IS" with no warranties, and confers no rights.
"Olaf Ollgaard" <User@.-NOSPAM-SqlJunkies.com> wrote in message
news:O7PuZUCYEHA.3716@.TK2MSFTNGP11.phx.gbl...
> I'm using Aggregate() with a custom data extension implementing the
IDataReaderExtension interface, to make RS use my
> own calculation of subtotals for matrices and lists, and this works just
fine as long as there is only one
> <GroupExpression> tag within each <GroupExpressions> tag, e.g.:
> <MatrixRows>
> <RowGroupings>
> <RowGrouping>
> <DynamicRows>
> <Grouping>
> <GroupExpressions>
> <GroupExpression>=Fields!Year.Value</GroupExpression>
> </GroupExpressions>
> </Grouping>
>
<ReportItems><Textbox><Value>=Fields!Year.Value</Value></Textbox></ReportIte
ms>
> </DynamicRows>
> </RowGrouping>
> <RowGrouping>
> <DynamicRows>
> <Grouping>
>
<GroupExpressions><GroupExpression>=Fields!Quarter.Value</GroupExpression></
GroupExpressions>
> </Grouping>
>
<ReportItems><Textbox><Value>=Fields!Quarter.Value</Value></Textbox></Report
Items>
> </DynamicRows>
> </RowGrouping>
> <RowGrouping>
> <DynamicRows>
> <Grouping>
>
<GroupExpressions><GroupExpression>=Fields!Month.Value</GroupExpression></Gr
oupExpressions>
> </Grouping>
>
<ReportItems><Textbox><Value>=Fields!Month.Value</Value></Textbox></ReportIt
ems>
> </DynamicRows>
> </RowGrouping>
> </RowGroupings>
> <MatrixRows>
> But when I don't want to show an intermediate grouping, like Quarter in
the above, but still want to group by it, the
> matrix cells are blank:
> <MatrixRows>
> <RowGroupings>
> <RowGrouping>
> <DynamicRows>
> <Grouping>
> <GroupExpressions>
> <GroupExpression>=Fields!Year.Value</GroupExpression>
> </GroupExpressions>
> </Grouping>
>
<ReportItems><Textbox><Value>=Fields!Year.Value</Value></Textbox></ReportIte
ms>
> </DynamicRows>
> </RowGrouping>
> <RowGrouping>
> <DynamicRows>
> <Grouping>
> <GroupExpressions>
> <GroupExpression>=Fields!Quarter.Value</GroupExpression>
> <GroupExpression>=Fields!Month.Value</GroupExpression>
> </GroupExpressions>
> </Grouping>
>
<ReportItems><Textbox><Value>=Fields!Month.Value</Value></Textbox></ReportIt
ems>
> </DynamicRows>
> </RowGrouping>
> </RowGroupings>
> <MatrixRows>
> The dataset is identical, and returns the same results for IsAggregateRow
etc.
> Can someone please tell me what I'm doing wrong or misunderstanding?
> Thanks!
> --
> Posted using Wimdows.net NntpNews Component -
> Post Made from http://www.SqlJunkies.com/newsgroups Our newsgroup engine
supports Post Alerts, Ratings, and Searching.
Friday, February 24, 2012
Group By
Hi,
I have the report,Report datasource is stored procedure.The stored procedure is returning results like this:
ID Name Count
1 Own Residence 50
2 Other Residence 20
3 xxxx 89
4 vvvvvv 78
Now i want to display the report like in the following format:
Name Count
Residence
Own 50
Other 20
xxxx 89
vvvvvv 78
How to achevie this
Thanks in advance
Assuming you can't change your store procedure.
To do this you need two distinct tables on your report designer surface. One will have a filter to get rid of all names without 'Residence'. Then, you simply list the names and counts in the details section.
Right underneth, you need to add a second table without heading/footer. This one will have a filter to get rid of the name with 'Residence'. Make the column widths match the one of your first table and things should align properly as if you were using a single table.
Good luck.
Sunday, February 19, 2012
Gridview Sorting
I have a gridview that has AllowSorting="true" however I need to implement my own sorting because I have DateTime and Integer data types in several of the columns and I don't want an int column sorted like 1,12,2,23,3,34,4,45,5,56, etc. So, I've added SortParameterName="sortBy" and adjusted my stored procedure to accept this. For only ASC sorting, I've got
ORDER BY
CASE WHEN @.sortBy='' THEN DateCreated END,
CASE WHEN @.sortBy='DateCreated' THEN DateCreated END
and so on. However, columns can also be sorted with DESC. I tried CASE WHEN @.sortBy='DateCreated DESC' THEN DateCreated DESC END, but I get a syntax error on DESC. How can I do this?
If your select is actually returning a datatype of int, it should sort normally. If it's returning an int in a varchar, then well...|||That's not what I was going for. I am using Atlas to do live searching/filtering of the gridview, and in order to use LIKE in my WHERE clause, I had to convert all datatypes to string. I've solved the problem by using
DECLARE @.sort AS varchar(63)
IF (RIGHT(@.sortBy,4)='DESC') BEGIN
SET @.sort=LEFT(@.sortBy,LEN(@.sortBy)-5)
END
ELSE BEGIN
SET @.sort=@.sortBy
END
with what I had before. Then in my code-behind, if "DESC" is part of the param, I start at the bottom of the table and insert rows into a new table.
If
sortBy.EndsWith("DESC")ThenDim dt2As DataTable = dt.CloneFor iAsInteger = dt.Rows.Count - 1To 0Step -1Dim rAs DataRow = dt.Rows(i)dt2.ImportRow(r)
Nextdt = dt2
EndIf