=IIF(Fields!a.value>100, True, False)
--------------------------------------------------------
=IIF(Fields!a.value >=10, "Green", IIF(Fields!a.value >=1, "Blue", "Red"))
values >=10 are green, between 1 & 9 are blue, less than 1 are red
--------------------------------------------------------
=SWITCH(
Fields!a.value >=10, "green",
Fields!a.value >=1, "blue",
Fields!a.value = 1, "yellow",
Fields!a.value <=0, "Red")
>=10 are green, between 1 & 9 blue, =1 yellow, <=0 red
--------------------------------------------------------
SWITCH function finds the first expression that's true. It will not catch errors further along.
IIF function evaluates all parts of the expression.
--------------------------------------------------------
=IIF(Rownumber("scope") Mod 2 = 0, "Khaki", "White")
set "scope" to reset row colours for every group
--------------------------------------------------------
Showing posts with label Function. Show all posts
Showing posts with label Function. Show all posts
Wednesday, 8 August 2012
Friday, 26 February 2010
Colour graduation function - SSRS

I needed to highlight date information dependant on it's proximity to todays date. Using a colour graduation, greater emphasis is placed on dates near todays and those in the future, while less emphasis is placed on historical dates.
I created a custom function:
Public Function MonthColourGraduation(ByVal ActualValue As integer, ByVal NeutralColour As String) As String
Select ActualValue
Case >-1
Return "#FFD2D2"
Case >-2
Return "#FFD5D5"
Case >-3
Return "#FFD9D9"
Case >-6
Return "#FFDDDD"
Case >-9
Return "#FFE1E1"
Case >-12
Return "#FFE4E4"
Case >-15
Return "#FFE8E8"
Case >-18
Return "#FFECEC"
Case >-21
Return "#FFF0F0"
Case >-24
Return "#FFF3F3"
Case >-30
Return "#FFF7F7"
Case >- 36
Return "#FFFBFB"
Case Else
Return NeutralColour
End Select
End Function
and for the table rows background colour:
=Code.MonthColourGraduation((DateDiff("m", now(),Fields!LastEndTime.Value)), "White")
To get the hex colour codes I used:
Thursday, 22 October 2009
Condensing large character string and removing carriage returns - SSRS
***Update ***
Function created:
for condensing a large character string and removing any carriage returns (such as in a comments field).
Function shortcomment(byval commentstring as string, stringlength as integer) as string
if commentstring="" or isnothing(commentstring)
return commentstring
else
commentstring=replace(commentstring, chr(10)," ")
if commentstring.length >stringlengthcommentstring=left(commentstring, stringlength) & "....."
return commentstring
else
return commentstring
end if
end if
end function
to implement:
=code.shortcomment(Fields!comments.Value, 10)
where 10 is the condensed length
Function created:
for condensing a large character string and removing any carriage returns (such as in a comments field).
Function shortcomment(byval commentstring as string, stringlength as integer) as string
if commentstring="" or isnothing(commentstring)
return commentstring
else
commentstring=replace(commentstring, chr(10)," ")
if commentstring.length >stringlengthcommentstring=left(commentstring, stringlength) & "....."
return commentstring
else
return commentstring
end if
end if
end function
to implement:
=code.shortcomment(Fields!comments.Value, 10)
where 10 is the condensed length
Labels:
Carriage Return,
CHR(10),
Condensing,
Function,
Left,
Length,
remove,
Replace,
SSRS
Subscribe to:
Posts (Atom)