April 2, 2014 at 3:22 am
Hi,
I have an issue setting up a SSRS report to display a matrix using dynamic fill colour (Heat Map).
I'm using a method whereby functions are declared and defined within "Code" section and called within the data regions.
Whatever I try to do the compiler returns an error:
"An unexpected error occurred while compiling expressions. Native compiler return value: '[BC30289] Statement cannot appear within a method body. End of method assumed.'.
The "Code" section in Report Properties is as follows:
Private LowVal as Decimal, HighVal as Decimal
Function SetHeatMapRange (LowValue as Decimal, HighValue as Decimal) As Object
LowVal = LowValue
HighVal = HighValue
End Function
Function HeatMapColor (ThisValue As Decimal) As String
Dim OutR As Byte, OutG As Byte, OutB As Byte
OutB = 0
OutR = 255 – ((ThisValue – LowVal) / (HighVal – LowVal)) * 255)
OutG = 255 * (((ThisValue – LowVal) / (HighVal – LowVal)))
Return “#” & Right(“0” & Hex(OutR),2) & Right(“0” & Hex(OutG),2) & Right(“0” & Hex(OutB),2)
Then the method I use is to use a textbox in the Report Header to determine the Low and High values for the coour range as follows:
Value expression is:
=Code.SetHeatMapRange(Min(Fields!Count.Value,"DataSet1"),Max(Fields!Count.Value,"DataSet1"))
I get the above mentioned error when previewing ONLY the above defined textbox WITHOUT any further colour expressions within the Matrix itself.
If I get the above working I can then define the background colour for the matrix cell as follows:
=Code.HeatMapColor(Fields!Count.Value)
Any ideas as to what is causing the above error.
By the way, I have tried placing the textbox within the body but same error occurs when placing in Report Header.
Thanks,
Dunc
April 2, 2014 at 3:58 am
sorry it didn't encapsulate the code snippets.
Here it is again:
Report Properties.Code
Private LowVal as Decimal, HighVal as Decimal
Function SetHeatMapRange (LowValue as Decimal, HighValue as Decimal) As Object
LowVal = LowValue
HighVal = HighValue
End Function
Function HeatMapColor (ThisValue As Decimal) As String
Dim OutR As Byte, OutG As Byte, OutB As Byte
OutB = 0
OutR = 255 – ((ThisValue – LowVal) / (HighVal – LowVal)) * 255)
OutG = 255 * (((ThisValue – LowVal) / (HighVal – LowVal)))
Return “#” & Right(“0” & Hex(OutR),2) & Right(“0” & Hex(OutG),2) & Right(“0” & Hex(OutB),2)
TextBox Expression
=Code.SetHeatMapRange(Min(Fields!Count.Value,"DataSet")
, Max(Fields!Count.Value,"DataSet"))
Fill Colour in Matrix Cell
=Code.HeatMapColor(Fields!Count.Value)
Thanks.
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply