Focal Point
[CLOSED] Second Max Value

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/1381057331/m/5987072976

November 09, 2015, 09:08 AM
luke
[CLOSED] Second Max Value
Hi Experts,

I have a report that returns the Max value from 24 samples, but I need to discard the maximum value and get the second max value.

SUM MAX.UNIT_LOAD_RNC.UNIT_LOAD_RNC.PEAK_LOAD/D20 AS 'PEAK'
BY UNIT_LOAD_RNC.UNIT_LOAD_RNC.RNC_NAME

Any help appreciated,

Luciano

This message has been edited. Last edited by: Tamra,


WebFOCUS 8.0.06
Windows, All Outputs
November 10, 2015, 08:14 PM
Dan Satchell
This example using the CAR file may help:

TABLE FILE CAR
 SUM SALES
 RANKED BY HIGHEST 2 COUNTRY
 WHERE TOTAL RNK.COUNTRY EQ 2 ;
END



WebFOCUS 7.7.05
November 11, 2015, 12:47 PM
George Patton
Dan is on the right track. I think you will have to do a HOLD with the top two values and then take the lesser of those two values for you final number.

You could also try sorting your data by the values and then use the LAST keyword to extract the value previous to the max.


WebFOCUS 7.7.05 Windows, Linux, DB2, IBM Lotus Notes, Firebird, Lotus Symphony/OpenOffice. Outputs PDF, Excel 2007 (for OpenOffice integration), WP
November 12, 2015, 12:57 PM
luke
Hi guys thank both of you for the tips. We are almost there.

Unfortunetely it is not going to work.
I'll try to explain using the anology below.

For each day we have 24hours, so I need to very each hour per day and get the second max Speed for each car.

If we use the sugestion:
RANKED BY HIGHEST 2 MAXSPEED
WHERE TOTAL RNK.MAXSPEED EQ 2 ;

The report will return only Porsche car.


Eg:
RANK MAXSPEED CAR 01/11/15 02/11/2015 03/11/2015
1 200 FERRARI 200 180 98
2 190 PORSCHE 100 190 120
3 180 MUSTANG 180 110 120
...
x


WebFOCUS 8.0.06
Windows, All Outputs
November 12, 2015, 03:37 PM
Dan Satchell
Add BY CAR if you want the second highest number for each car:

TABLE FILE CAR
 BY CAR
 RANKED BY HIGHEST 2 SALES
 WHERE TOTAL RNK.SALES EQ 2 ;
END

This assumes your 24 hours of data is vertical (one entry for each hour) instead of horizontal (each entry has 24 hour buckets).


WebFOCUS 7.7.05