Friday, March 30, 2012

RunningValue()

I have a report that I has a dataset that has a column that can have high and low values. If a row has a value that exceeds either of these values I would like to do a running value on these values. For example, 300 records , 10 high , 3 low.

I know I can do a SQL query that can grab that data and then do a countrows on that dataset but I thought there should be a way of doing a runningvalue for each value.

Anyone have an idea on what the syntax is to do this?

I have also tried using 2 functions in custom code that are doing a simple if else to return the += 1 count for high and low. The value is displayed in a column that I'm hiding but I'm not able to display that variable anywhere else. I tried =Code.DisplayHigh() and it always returns nothing but in my columns I'm getting the right values.

Dim HighCount
Dim LowCount

Public Function CheckHigh(x As Double) As Integer
If x > 120.5 Then
HighCount += 1
Return HighCount
Else
Return 0
End If
End Function

Public Function CheckLow(x As Double) As Integer
If x < 116.2 Then
LowCount += 1
Return LowCount
Else
Return 0
End If
End Function

Public Function DisplayHigh()
Return HighCount
End Function

use properties (set and get ) and set the value and access the value using those. I cant say whats not working, because dont know whats the class structure. But try that first, is to convert these to properties.

No comments:

Post a Comment