Friday, February 17, 2012
counting pages etc
first page ONLY ,and other stuff hidden on the first page..
I'm having a lot of problems
in the end i want to put hidden.visibility to be based on some logic,
but i've found no way to differentiate the pages..
for example i try this custom code, to test something out, figure that
i should get a incremental increase everytime it is called
public shared thecount as integer = 0
Public Function docount as Integer
thecount = thecount + 1
return thecount
End Function
but inside the tables header i have
=Code.docount
and it shows 0 on every page..
anybody else pulled their hair out on this one, and has come through
the other side?I have an example of putting items in the footer on the first page only at
www.MSBICentral.com
It does not try to count pages, but can tell if this is the first
page...The File is called PageFooterOnFirstOnly.RDL
It is in the downloads section... Hope this helps..
--
Wayne Snyder, MCDBA, SQL Server MVP
Mariner, Charlotte, NC
www.mariner-usa.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org
"Karl Prosser" <klumsy@.xtra.co.nz> wrote in message
news:7156880c.0502151713.2432cd30@.posting.google.com...
> i'm trying to make certian stuff inside a table header be shown on the
> first page ONLY ,and other stuff hidden on the first page..
> I'm having a lot of problems
> in the end i want to put hidden.visibility to be based on some logic,
> but i've found no way to differentiate the pages..
> for example i try this custom code, to test something out, figure that
> i should get a incremental increase everytime it is called
> public shared thecount as integer = 0
> Public Function docount as Integer
> thecount = thecount + 1
> return thecount
> End Function
> but inside the tables header i have
> =Code.docount
> and it shows 0 on every page..
> anybody else pulled their hair out on this one, and has come through
> the other side?|||thanks for the example, but making a footer only show on the first page
was not my problem since headers and footers can look at the global
page counter, it was something in the body, in the header of a table..
i could use repeatonnewpage, however i needed some header stuff to show
sometimes and some not to. and i found that that even though a table
header can have many rows and each row has a repeat on new page
property, if you change one row, it changes them all, anyhow i managed
to do it with created another group, a dummy group and having my logic
in there..
also i found out why my example code above didn't work, it seems RS
only calculates the table header once (even though it repeats it on
subsequent pages, it doesn't recalculaste it, just reuses whatever was
last calculated)
Karl
Wayne Snyder wrote:
> I have an example of putting items in the footer on the first page
only at
> www.MSBICentral.com
> It does not try to count pages, but can tell if this is the first
> page...The File is called PageFooterOnFirstOnly.RDL
> It is in the downloads section... Hope this helps..
> --
> Wayne Snyder, MCDBA, SQL Server MVP
> Mariner, Charlotte, NC
> www.mariner-usa.com
> (Please respond only to the newsgroups.)
> I support the Professional Association of SQL Server (PASS) and it's
> community of SQL Server professionals.
> www.sqlpass.org
> "Karl Prosser" <klumsy@.xtra.co.nz> wrote in message
> news:7156880c.0502151713.2432cd30@.posting.google.com...
> > i'm trying to make certian stuff inside a table header be shown on
the
> > first page ONLY ,and other stuff hidden on the first page..
> > I'm having a lot of problems
> > in the end i want to put hidden.visibility to be based on some
logic,
> > but i've found no way to differentiate the pages..
> >
> > for example i try this custom code, to test something out, figure
that
> > i should get a incremental increase everytime it is called
> >
> > public shared thecount as integer = 0
> > Public Function docount as Integer
> > thecount = thecount + 1
> > return thecount
> > End Function
> >
> > but inside the tables header i have
> > =Code.docount
> >
> > and it shows 0 on every page..
> >
> > anybody else pulled their hair out on this one, and has come
through
> > the other side?
counting occurrences of a value
I have a column in a report with values Y or N or V. In the header, I have to show the number of times each value appeared.
I used RepeatingValue() with IIF() but it's counting all the values as same, e.g., if there are four occurrences of Y, two of N and one of V, I want something like this:
Y Cnt=4, N Cnt=2, V Cnt=1
My assumption was that this will work (white spaces added for readability:
=iif(
Fields!myCol.Value = "Y",
"Y Cnt=" & RunningValue(Fields!myCol.Value, Count, "dsMyDataSet"),
iif(Fields!myCol.Value = "N",
"N Cnt= & RunningValue(Fields!myCol.Value, Count, "dsMyDataSet"),
iif(Fields!myCol.Value = "V",
"V Cnt= & RunningValue(Fields!myCol.Value, Count, "dsMyDataSet"),
"NULL"
)
)
)
Please help.
Can we declare variables and use them to keep the total?|||As before, no one could help. After trying millions of different ways, I found the solution (white spaces for readability):
="Y Cnt=" &
Count(
Switch(Fields!myCol.Value = "Y", 1)
, "dsMyDataSet"
)
& ", N Cnt=" &
Count(
Switch(Fields!myCol.Value = "N", 1)
, "dsMyDataSet"
)
& ", V Cnt=" &
Count(
Switch(Fields!myCol.Value = "V", 1)
, "dsMyDataSet"
)
Tuesday, February 14, 2012
Counting Groups
little luck. If I create a data set with :
"Declare @.StartCount int
Set @.StartCount = 1
Select @.StartCount as Start"
Then pull the sum of the field into the group header, the very first number
it starts off with is 7, not 1. If I just pull the field itself, it returns
1 every time the group header repeats itself. If I don't use the set
statement, but set the input as a parameter with a default of 1, I get 1
every time the group repeats itself.
So, I went search on how to declare a variable as a counter and found a post
titled "Line Item Count" which contains part of the information I'm looking
for, but no details. David Siebert said:
"You could use custom code (under report properties) to increment a variable
for each row."
Unfortunately, not knowing VB very well, I have no idea how to implement
this. I tried doing a Dim statement in that window, then putting a textbox
on the line in question with an expression of "=Count(Counter + 1)", but I
keep getting a "Counter not declared" error message when I try to preview.
Can anyone help me out?
Thanks in advance,
Catadmin
--
MCDBA, MCSA
Random Thoughts: I only thought I was going crazy. I forgot I was already
there.Not sure why you are doing this but... anyway.
Put this code in your code section of report properties:
Public Shared gintCnt As Integer ' This will hold the count.
Public Shared Function IncDispCnt() As String
' This function will increment count and output result.
gintCnt += 1
Return gintCnt.ToString
End Function
Public Shared Function DisplayCnt() As String
' This function will output result.
Return gintCnt.ToString
End Function
Public Shared Function IncCnt() As String
' This function will increment count.
gintCnt += 1
Return ""
End Function
Public Shared Function ResetCnt() As String
' This function will increment count.
gintCnt = 0
Return ""
End Function
I gave you a few options there. Add a textbox to the header you want to
count and place this in the expression:
=Code.IncCnt()
In the page footer add a textbox and place this in the expression:
=Code.DisplayCnt()
That should do it.
--
Message posted via http://www.sqlmonster.com|||oops, the comment for ResetCnt should be:
' This function will reset the global count.
--
Message posted via http://www.sqlmonster.com|||> Not sure why you are doing this
I'm doing this because I've got a group that repeats its headers halfway
down the page. I just want the headers at the top of the page, so I'm using
the counter to trigger the visibility property on that particular header. If
the counter > 1 on a page, then hide. Else show. Then I reset the counter
at the page footer.
Your code worked perfectly! I just could figure it out to save my life. Of
course, I wasn't looking at using functions either.
Thank you so very very very much. You taught me something valuable today.
Catadmin
--
MCDBA, MCSA
Random Thoughts: If a person is Microsoft Certified, does that mean that
Microsoft pays the bills for the funny white jackets that tie in the back?
@.=)
"Patrick P via SQLMonster.com" wrote:
but... anyway.
> Put this code in your code section of report properties:
> Public Shared gintCnt As Integer ' This will hold the count.
> Public Shared Function IncDispCnt() As String
> ' This function will increment count and output result.
> gintCnt += 1
> Return gintCnt.ToString
> End Function
> Public Shared Function DisplayCnt() As String
> ' This function will output result.
> Return gintCnt.ToString
> End Function
> Public Shared Function IncCnt() As String
> ' This function will increment count.
> gintCnt += 1
> Return ""
> End Function
> Public Shared Function ResetCnt() As String
> ' This function will increment count.
> gintCnt = 0
> Return ""
> End Function
> I gave you a few options there. Add a textbox to the header you want to
> count and place this in the expression:
> =Code.IncCnt()
> In the page footer add a textbox and place this in the expression:
> =Code.DisplayCnt()
> That should do it.
> --
> Message posted via http://www.sqlmonster.com
>