Showing posts with label columni. Show all posts
Showing posts with label columni. Show all posts

Sunday, February 19, 2012

Column Header Color

Is there a way in SSRS to conditionally set the color of a column?

I want to do something like:

=IFF(some condition, Color(Fields!Date, "Green"), Color(Fields!Date, "Red"))

Yes you go into the Color property of the text box in the Detail row of the table and set the color to an <expression..> then in the dialog that comes up enter somthing like this...

=iif(Fields!Name.Value = "Smith", "Green", "Red")

if the name = smith make the color green other wise make it red

the key point being that you go to the property and set the property equal to an expression.

if you need more value/color options you can put in a little code in the report that you can reference from the expression.

1. right click in the little box at the top left of the report (intersection of the vertical and horizontal rulers) in the designer and choose properties.

2. select the code tab

3. type in some VB code

ex.

Public Function GetColor(ByVal sname as String) as String
IF sname = "Smith" Then
Return "Blue"
End IF
IF sname = "Jones" Then
Return "Black"
End IF
IF sname = "Woods" Then
Return "Red"
End IF
End Function

4. set the color or background property to =code.GetColor(Fields!Name.Value)

================= off topic FYI

here is another example of a little code for the report that can be used in an expression

this is used in a calulated field in a dataset =Code.GetBox(Fields!Percentile.Value,Fields!Importance.Value)


Public Function GetBox(ByVal PercentImp As Integer, ByVal Important As Integer) As Integer

Select Case Important
Case 1
Select Case PercentImp
Case 0 To 39
GetBox = 1
Case 40 To 75
GetBox = 2
Case Is > 75
GetBox = 3
End Select

Case 2
Select Case PercentImp
Case 0 To 39
GetBox = 4
Case 40 To 75
GetBox = 5
Case Is > 75
GetBox = 6
End Select
Case 3
Select Case PercentImp
Case 0 To 39
GetBox = 7
Case 40 To 75
GetBox = 8
Case Is > 75
GetBox = 9
End Select

End Select

End Function

|||You've made my day. Totally sweet. Thank you!!!

Column Header Color

Is there a way in SSRS to conditionally set the color of a column?

I want to do something like:

=IFF(some condition, Color(Fields!Date, "Green"), Color(Fields!Date, "Red"))

Yes you go into the Color property of the text box in the Detail row of the table and set the color to an <expression..> then in the dialog that comes up enter somthing like this...

=iif(Fields!Name.Value = "Smith", "Green", "Red")

if the name = smith make the color green other wise make it red

the key point being that you go to the property and set the property equal to an expression.

if you need more value/color options you can put in a little code in the report that you can reference from the expression.

1. right click in the little box at the top left of the report (intersection of the vertical and horizontal rulers) in the designer and choose properties.

2. select the code tab

3. type in some VB code

ex.

Public Function GetColor(ByVal sname as String) as String
IF sname = "Smith" Then
Return "Blue"
End IF
IF sname = "Jones" Then
Return "Black"
End IF
IF sname = "Woods" Then
Return "Red"
End IF
End Function

4. set the color or background property to =code.GetColor(Fields!Name.Value)

================= off topic FYI

here is another example of a little code for the report that can be used in an expression

this is used in a calulated field in a dataset =Code.GetBox(Fields!Percentile.Value,Fields!Importance.Value)


Public Function GetBox(ByVal PercentImp As Integer, ByVal Important As Integer) As Integer

Select Case Important
Case 1
Select Case PercentImp
Case 0 To 39
GetBox = 1
Case 40 To 75
GetBox = 2
Case Is > 75
GetBox = 3
End Select

Case 2
Select Case PercentImp
Case 0 To 39
GetBox = 4
Case 40 To 75
GetBox = 5
Case Is > 75
GetBox = 6
End Select
Case 3
Select Case PercentImp
Case 0 To 39
GetBox = 7
Case 40 To 75
GetBox = 8
Case Is > 75
GetBox = 9
End Select

End Select

End Function

|||You've made my day. Totally sweet. Thank you!!!

Thursday, February 16, 2012

Column default value

Hi,
Anyone of you know how to change the default value for an existing column?
I have the script below but it might be a problem to run this script on
different server because the default constraint name might be different. Any
efficient way to solve this problem?
ALTER TABLE AcctSettings DROP CONSTRAINT DF_ShowOrganizationWidePopup
GO
ALTER TABLE [dbo].[AcctSettings] ADD
CONSTRAINT [DF_AcctSettings_ShowOrganization] DEFAULT( 0 ) FOR
[ShowOrganizationWidePopup]
GO
Thanks,
KennyKenny
See INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE view to get the name of
contraint
"Kenny" <keejh@.hotmail.com> wrote in message
news:%23DcH9j%23%23FHA.3676@.tk2msftngp13.phx.gbl...
> Hi,
> Anyone of you know how to change the default value for an existing column?
> I have the script below but it might be a problem to run this script on
> different server because the default constraint name might be different.
> Any efficient way to solve this problem?
> ALTER TABLE AcctSettings DROP CONSTRAINT DF_ShowOrganizationWidePopup
> GO
> ALTER TABLE [dbo].[AcctSettings] ADD
> CONSTRAINT [DF_AcctSettings_ShowOrganization] DEFAULT( 0 ) FOR
> [ShowOrganizationWidePopup]
> GO
> Thanks,
> Kenny
>|||Before dropping an existing constraint you should know its name. If the name
was created automatically (if the constraint was "created by clicking, rathe
r
by typing" :)), you need to identify its name first either by looking at the
objects in QA or by inspecting the INFORMATION_SCEMA views.
ML
http://milambda.blogspot.com/|||Unfortunately, default names are not in the information_schema tables (at le
ast not in
CONSTRAINT_COLUMN_USAGE). This is because in ANSI SQL, a default is a column
attribute, not a
constraint.
So one would have to look up the name in sysobjects and syscolumns.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"ML" <ML@.discussions.microsoft.com> wrote in message
news:02BFC401-F554-41C7-95FD-7B0D19071702@.microsoft.com...
> Before dropping an existing constraint you should know its name. If the na
me
> was created automatically (if the constraint was "created by clicking, rat
her
> by typing" :)), you need to identify its name first either by looking at t
he
> objects in QA or by inspecting the INFORMATION_SCEMA views.
>
> ML
> --
> http://milambda.blogspot.com/|||Tibor

> Unfortunately, default names are not in the information_schema tables (at
> least not in CONSTRAINT_COLUMN_USAGE). This is because in ANSI SQL, a
> default is a column attribute, not a constraint.
Yes, you are right, how could I forget about it.
Thanks
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:%23svTrw%23%23FHA.4088@.TK2MSFTNGP09.phx.gbl...
> Unfortunately, default names are not in the information_schema tables (at
> least not in CONSTRAINT_COLUMN_USAGE). This is because in ANSI SQL, a
> default is a column attribute, not a constraint.
> So one would have to look up the name in sysobjects and syscolumns.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
> Blog: http://solidqualitylearning.com/blogs/tibor/
>
> "ML" <ML@.discussions.microsoft.com> wrote in message
> news:02BFC401-F554-41C7-95FD-7B0D19071702@.microsoft.com...
>