Need a view to return only entries with the higest value

Is there a command that will allow me to only show the highest number of a field?

Example:

Lets say that I have three entries for each of my sales people.

Name Week Sales

John 1 100.00

John 2 150.00

John 3 50.00

Jim 1 50.00

Jim 2 50.00

Jim 3 100.00

Jack 1 200.00

Jack 2 100.00

Jack 2 150.00

I would like to know if there is a way to grab the values of that last field and then only displays the highest one for each sales person. Like So:

Name Week Sales

John 2 150.00

Jane 3 100.00

Jack 1 200.00

Any help would be much appreciated.

Subject: Need a view to return only entries with the higest value

Hello.

Earlier I made a script to loop through an unknown number of elements and pick the highest and the lowest value from the selection. I created my own sub called GetMinMaxValues.

Maybe you can use some of this logic to solve your case.

Sub GetMinMaxValues

Dim MyRes As Variant

z=0 'Reset counter

Handle = 0 'Deposit for the x value

Interval = 67 'Default interval between elements of same type in list

For x = 27 To 51 Step 3 'Loop through all element one by one (number = place in record)

Handle = x

For y = 1 To utvalg 'Loop through all choosen records

If y = 1 Then 'First record?

MyRes = chm(x)

elementer(y) = Val(MyRes) 'Populate array with first value from record (translated to value)

Else

x=x+Interval

MyRes = chm(x)

elementer(y) = Val(MyRes) 'Populate array with next value from record (translated to value)

End If

Next 'Next record

Forall num In elementer 'Loop through all elements

If(num<ElementMin) Then

ElementMin=num 'Compare to find lowest value

End Forall

ElementResult(z)=ElementMin 'Store the lowest value from the result list

z=z+1 'Increase counter

Forall num In elementer 'Loop through all elements If(num>ElementMax) Then

ElementMax=num 'Compare to find lowest value

End Forall

ElementResult(z)=ElementMax 'Store the highest value from the result list

z=z+1 'Increase conter

Erase Elementer 'Empty the result list for reuse

’ ElementResult(n) hold the result for all min/max chemical properties in this order:

’ Cu - Zn - Pb - Sn - Al - Fe - Ni - Mn - Si

’ First the low values are stored then the corresponding high values from each element

Print ElementMin, " ", ElementMax

ElementMin = 100 'Reset to default value for the element list (high to low)

ElementMax = 0 'Reset to default value for the element list (low to high)

x = Handle

Next 'Next element

End Sub

Subject: Need a view to return only entries with the higest value

You should capture the names and values as a separate field. Something like this:

dim uniquenames as variant

dim newvals() as string

dim itemName as notesitem

dim itemWeek as notesitem

dim itemSales as notesitem

dim i as integer, n as integer

dim h as integer, f as integer

dim salesmax as double

dim t as integer

dim week as double

with doc

set itemName = .getfirstitem(“Name”)

set itemWeek = .getfirstitem(“Week”)

set itemSales = .getfirstitem(“Sales”)

end with

t = 0

uniquenames = Evaluate(“@Unique(Name)”,doc)

n = ubound(uniquenames)

for i = 0 to n

salesmax = 0

’ Step through each name value, testing the ones that match this name.

h = ubound(itemName.values)

for f = 0 to h

if itemName.values(f) = uniquenames(i) then

 if itemSales.values(f) > salesmax then salesmax = itemSales.values(f):week = itemWeek.values(f)

end if

next f

’ Drop that name and sales value in the array

redim preserve newvals(t) as string

newvals(t) = uniquenames(n) & " Week " & cstr(week) & " $" & cstr(salesmax)

t = t + 1

next i

Then stick the newvals array into an item to use in the view.

Of course this arrangement is very crude an inefficient because it updates each doc every time even if no data has changed. That is if Joe smith’s highest sales number is still Week 2, the document gets updated anyway. This is a bad practice. It would be better to introduce an intermediate step where the name/week/sales number trios are captured as a separate item. For example item SALES_SNAPSHOT could hold values {“Joe Smith$$2$$150”;“Larry Smith$$1$$200”} and so on. As you run through your big multivalue item, you compare each salesmax-and-week pair to the values from sales_snapshot for that name, and update the snaphot (and the newvals array etc) only if the week or salesmax has changed.

In sum, you’re trying to capture structured data in Notes and there’s no good way to do that. But as you can see, capturing the data in a big multivalue field up front is the wrong way to go. You should figure out a way to capture the data in structured form first, then use your multivalue field (or whatever) to display a synopsis of that data. What you have now more closely resembles the presentation of structured data than it does the storage of that data, and that’s why this seems so hard.

Subject: Need a view to return only entries with the higest value

Thank you both very much.

Very good info.