Wednesday, March 7, 2012
How to count up group number
I have a report with a group and detail rows. I want to count up the groups
in the column groupnumber.
I tried the rownumber(<scope>) function.
If I use rownumber (Nothing) the detail rows were counted.
If I use rownumber("Groupname") the Report Server shows the number of detail
rows for each group.
Which scope should I use to count up the single groups?
Best regards,
StefanMaybe declare a global variable (i) in the Custom code and add this variable
in the value of a field in your group (i.e. =i+1)
"Stefoon23" wrote:
> Hi,
> I have a report with a group and detail rows. I want to count up the groups
> in the column groupnumber.
> I tried the rownumber(<scope>) function.
> If I use rownumber (Nothing) the detail rows were counted.
> If I use rownumber("Groupname") the Report Server shows the number of detail
> rows for each group.
> Which scope should I use to count up the single groups?
> Best regards,
> Stefan|||Hi Kyriakos,
your answer makes sense. But I couldn't get it to work!
How do I declare a custom global variable and how could I access it in the
report?
Best regards,
Stefan
"Kyriakos" wrote:
> Maybe declare a global variable (i) in the Custom code and add this variable
> in the value of a field in your group (i.e. =i+1)
> "Stefoon23" wrote:
> > Hi,
> >
> > I have a report with a group and detail rows. I want to count up the groups
> > in the column groupnumber.
> >
> > I tried the rownumber(<scope>) function.
> > If I use rownumber (Nothing) the detail rows were counted.
> > If I use rownumber("Groupname") the Report Server shows the number of detail
> > rows for each group.
> > Which scope should I use to count up the single groups?
> >
> > Best regards,
> > Stefan|||Add this code at your custom code section
============Public Shared i as integer
Public Function GetGrp() As Integer
i +=1
Return i
End Function
============
then call the function within a field on the group level, i.e. =Code.GetGrp()
That should do the count.
"Stefoon23" wrote:
> Hi Kyriakos,
> your answer makes sense. But I couldn't get it to work!
> How do I declare a custom global variable and how could I access it in the
> report?
> Best regards,
> Stefan
> "Kyriakos" wrote:
> > Maybe declare a global variable (i) in the Custom code and add this variable
> > in the value of a field in your group (i.e. =i+1)
> >
> > "Stefoon23" wrote:
> >
> > > Hi,
> > >
> > > I have a report with a group and detail rows. I want to count up the groups
> > > in the column groupnumber.
> > >
> > > I tried the rownumber(<scope>) function.
> > > If I use rownumber (Nothing) the detail rows were counted.
> > > If I use rownumber("Groupname") the Report Server shows the number of detail
> > > rows for each group.
> > > Which scope should I use to count up the single groups?
> > >
> > > Best regards,
> > > Stefan|||Hi Kyriakos, it worked perfectly!
Thanks for your help!
Stefoon
"Kyriakos" wrote:
> Add this code at your custom code section
> ============> Public Shared i as integer
> Public Function GetGrp() As Integer
> i +=1
> Return i
> End Function
> ============> then call the function within a field on the group level, i.e. =Code.GetGrp()
>
> That should do the count.
> "Stefoon23" wrote:
> > Hi Kyriakos,
> > your answer makes sense. But I couldn't get it to work!
> > How do I declare a custom global variable and how could I access it in the
> > report?
> >
> > Best regards,
> > Stefan
> >
> > "Kyriakos" wrote:
> >
> > > Maybe declare a global variable (i) in the Custom code and add this variable
> > > in the value of a field in your group (i.e. =i+1)
> > >
> > > "Stefoon23" wrote:
> > >
> > > > Hi,
> > > >
> > > > I have a report with a group and detail rows. I want to count up the groups
> > > > in the column groupnumber.
> > > >
> > > > I tried the rownumber(<scope>) function.
> > > > If I use rownumber (Nothing) the detail rows were counted.
> > > > If I use rownumber("Groupname") the Report Server shows the number of detail
> > > > rows for each group.
> > > > Which scope should I use to count up the single groups?
> > > >
> > > > Best regards,
> > > > Stefan|||Hi Kyriakos,
I wrote it works perfectly. It works when I Render the report the first
time. But when I choose other parameters the counting is not initialized.
Thus it does not start at zero but at the highest number.
e.g. I have a report with 5 group members for a group level the count would
go from 1 to 5 the first time I render the report. The second time the
numbers would reach from 6 to 10. ;-)
How could I initialize the value of the global variable every time the
report is rendered again? Or maybe it would be a solution to init the value
when the report has finished rendering.
Best regards,
Stefoon
"Kyriakos" wrote:
> Add this code at your custom code section
> ============> Public Shared i as integer
> Public Function GetGrp() As Integer
> i +=1
> Return i
> End Function
> ============> then call the function within a field on the group level, i.e. =Code.GetGrp()
>
> That should do the count.
> "Stefoon23" wrote:
> > Hi Kyriakos,
> > your answer makes sense. But I couldn't get it to work!
> > How do I declare a custom global variable and how could I access it in the
> > report?
> >
> > Best regards,
> > Stefan
> >
> > "Kyriakos" wrote:
> >
> > > Maybe declare a global variable (i) in the Custom code and add this variable
> > > in the value of a field in your group (i.e. =i+1)
> > >
> > > "Stefoon23" wrote:
> > >
> > > > Hi,
> > > >
> > > > I have a report with a group and detail rows. I want to count up the groups
> > > > in the column groupnumber.
> > > >
> > > > I tried the rownumber(<scope>) function.
> > > > If I use rownumber (Nothing) the detail rows were counted.
> > > > If I use rownumber("Groupname") the Report Server shows the number of detail
> > > > rows for each group.
> > > > Which scope should I use to count up the single groups?
> > > >
> > > > Best regards,
> > > > Stefan|||I could solve the puzzle by myself:
add some more custom code to your project
===================Public Shared i as integer = 0
Public Function GetGrp() As Integer
i +=1
Return i
End Function
Public Function InitGrp() As Integer
i=0
Return i
End Function
=======================
Put the Function InitGrp() to the page header.
Best regards,
Stefoon
"Stefoon23" wrote:
> Hi Kyriakos,
> I wrote it works perfectly. It works when I Render the report the first
> time. But when I choose other parameters the counting is not initialized.
> Thus it does not start at zero but at the highest number.
> e.g. I have a report with 5 group members for a group level the count would
> go from 1 to 5 the first time I render the report. The second time the
> numbers would reach from 6 to 10. ;-)
> How could I initialize the value of the global variable every time the
> report is rendered again? Or maybe it would be a solution to init the value
> when the report has finished rendering.
> Best regards,
> Stefoon
>
> "Kyriakos" wrote:
> > Add this code at your custom code section
> >
> > ============> > Public Shared i as integer
> >
> > Public Function GetGrp() As Integer
> > i +=1
> > Return i
> > End Function
> > ============> >
> > then call the function within a field on the group level, i.e. =Code.GetGrp()
> >
> >
> > That should do the count.
> >
> > "Stefoon23" wrote:
> >
> > > Hi Kyriakos,
> > > your answer makes sense. But I couldn't get it to work!
> > > How do I declare a custom global variable and how could I access it in the
> > > report?
> > >
> > > Best regards,
> > > Stefan
> > >
> > > "Kyriakos" wrote:
> > >
> > > > Maybe declare a global variable (i) in the Custom code and add this variable
> > > > in the value of a field in your group (i.e. =i+1)
> > > >
> > > > "Stefoon23" wrote:
> > > >
> > > > > Hi,
> > > > >
> > > > > I have a report with a group and detail rows. I want to count up the groups
> > > > > in the column groupnumber.
> > > > >
> > > > > I tried the rownumber(<scope>) function.
> > > > > If I use rownumber (Nothing) the detail rows were counted.
> > > > > If I use rownumber("Groupname") the Report Server shows the number of detail
> > > > > rows for each group.
> > > > > Which scope should I use to count up the single groups?
> > > > >
> > > > > Best regards,
> > > > > Stefan|||:-)
"Stefoon23" wrote:
> I could solve the puzzle by myself:
> add some more custom code to your project
> ===================> Public Shared i as integer = 0
> Public Function GetGrp() As Integer
> i +=1
> Return i
> End Function
>
> Public Function InitGrp() As Integer
> i=0
> Return i
> End Function
> =======================> Put the Function InitGrp() to the page header.
> Best regards,
> Stefoon
> "Stefoon23" wrote:
> > Hi Kyriakos,
> > I wrote it works perfectly. It works when I Render the report the first
> > time. But when I choose other parameters the counting is not initialized.
> > Thus it does not start at zero but at the highest number.
> > e.g. I have a report with 5 group members for a group level the count would
> > go from 1 to 5 the first time I render the report. The second time the
> > numbers would reach from 6 to 10. ;-)
> >
> > How could I initialize the value of the global variable every time the
> > report is rendered again? Or maybe it would be a solution to init the value
> > when the report has finished rendering.
> >
> > Best regards,
> > Stefoon
> >
> >
> >
> > "Kyriakos" wrote:
> >
> > > Add this code at your custom code section
> > >
> > > ============> > > Public Shared i as integer
> > >
> > > Public Function GetGrp() As Integer
> > > i +=1
> > > Return i
> > > End Function
> > > ============> > >
> > > then call the function within a field on the group level, i.e. =Code.GetGrp()
> > >
> > >
> > > That should do the count.
> > >
> > > "Stefoon23" wrote:
> > >
> > > > Hi Kyriakos,
> > > > your answer makes sense. But I couldn't get it to work!
> > > > How do I declare a custom global variable and how could I access it in the
> > > > report?
> > > >
> > > > Best regards,
> > > > Stefan
> > > >
> > > > "Kyriakos" wrote:
> > > >
> > > > > Maybe declare a global variable (i) in the Custom code and add this variable
> > > > > in the value of a field in your group (i.e. =i+1)
> > > > >
> > > > > "Stefoon23" wrote:
> > > > >
> > > > > > Hi,
> > > > > >
> > > > > > I have a report with a group and detail rows. I want to count up the groups
> > > > > > in the column groupnumber.
> > > > > >
> > > > > > I tried the rownumber(<scope>) function.
> > > > > > If I use rownumber (Nothing) the detail rows were counted.
> > > > > > If I use rownumber("Groupname") the Report Server shows the number of detail
> > > > > > rows for each group.
> > > > > > Which scope should I use to count up the single groups?
> > > > > >
> > > > > > Best regards,
> > > > > > Stefan
How to count the number of textboxes
Hi all,
In the report I am working on, I have a "textbox39" in a table which has groups. I want to have another "textbox29" outside the table to count the number of "textbox39"s that are actually displayed and also the number of "textbox1"s that have a certain value (e.g. "1") in the final report. I tried to use "Sum(ReportItems!textbox39.Value)" but the compiler complains
Error 1 [rsAggregateReportItemInBody] The Value expression for the textbox 'textbox29' uses an aggregate function on a report item. Aggregate functions can be used only on report items contained in page headers and footers. d:\perf\perfreportingproject\PerformanceTestDetails v.3.rdl 0 0
Error 7 [rsReportItemReference] The Value expression for the textbox ‘textbox29’ refers to the report item ‘textbox39’. Report item expressions can only refer to other report items within the same grouping scope or a containing grouping scope. d:\perf\perfreportingproject\PerformanceTestDetails v.3.rdl 0 0
Anybody has any idea how to solve it?
Thanks so much,
Zhiyan
What are you actually trying to do in terms of the data? Are you trying to count how many groups there are? Or count the number of items in a group? Have you tried using the RowCount or RunningValue function on the data fields?|||Suppose there is a long expression which displays color "Red" and "Green" in textbox39, I want to count the number of Reds and Greens in my report. Now I can get the total number of textbox39s by multipling the number rows and columns. But when I tried to count the colors, the compiler complains:
Error 1 [rsAggregateofAggregate] The Value expression for the textbox 'textbox27' contains an aggregate function (or RunningValue or RowNumber functions) in the argument to another aggregate function (or RunningValue). Aggregate functions cannot be nested inside other aggregate functions. d:\perf\perfreportingproject\PerformanceTestDetails v.3.rdl 0 0
Error 2 [rsAggregateofAggregate] The Value expression for the textbox 'textbox27' contains an aggregate function (or RunningValue or RowNumber functions) in the argument to another aggregate function (or RunningValue). Aggregate functions cannot be nested inside other aggregate functions. d:\perf\perfreportingproject\PerformanceTestDetails v.3.rdl 0 0
Any ideas?
Thanks!
How to count number of Groups in MS-SQL ?
Select Count(1) FROM (Select ShipRegion, Sum(FREIGHT) as [TotalFreight]from ORDERS WHERE OrderID < 123456 GROUP BY ShipRegion )
Thanks,
Frankk
Hello,
this seems to work:
> Select Count(1) FROM (Select ShipRegion, Sum(FREIGHT) as [TotalFreight] from ORDERS WHERE OrderID < 123456 GROUP BY ShipRegion) AS X
Hope this helps. -LV
|||LV,
Thanks, it works !!!!!
Frankk