Focal Point
[SOLVED] max value of compute in header

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

February 10, 2009, 09:51 PM
Mayor
[SOLVED] max value of compute in header
for some reason, I am only getting a maximum value in a compute (created in a previous hold) to display only the first record max value for only the first instance read for an all selection rather than for all the different rows or instances created. How can I get the compute to read in all the different instances and than take in the max value that is there in all. Afterwhich, display that in the header? I was thinking of a counter, but not sure what that would entail for this.

thanks in advance!

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



Production & Development: WebFocus 7.6.4
February 10, 2009, 11:43 PM
Francis Mariani
You may be able to use a multi-verb request, one to calculate the MAX over all value and the other for the normal request. Something like this:

SET ASNAMES=ON
SET HOLDFORMAT=ALPHA
SET HOLDLIST=PRINTONLY

TABLE FILE CAR
SUM MAX.SALES AS 'TMAX_SALES'
SUM MAX.SALES AS 'MAX_SALES'
BY COUNTRY
BY CAR
ON TABLE HOLD AS H001
END

TABLE FILE H001
PRINT MAX_SALES
BY COUNTRY
BY CAR
HEADING
"MAX SALES: <TMAX_SALES"
" "
END



Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
February 12, 2009, 04:09 PM
Mayor
Okay I see, thanks Francis. So what if I have a compute statement that needs several by statements to sort, all in a previous hold file. So far I created another hold to do this. The code looks something like:

TABLE FILE ALL_LOGS
PRINT
LOGIN_DATE
LOGIN_MONTH
LOGIN_YEAR
LOGIN_DAY
LOG_STATE
SORT_DATE
OS_USERNAME
USERNAME
ALPHA_MONTH
FULL_MONTH
COMPUTE LCOUNTER/I4 = IF USERNAME NE LAST USERNAME THEN 1
ELSE IF LOG_STATE EQ 'ON' THEN (LAST LCOUNTER + 1) ELSE (LAST LCOUNTER - 1);
COMPUTE ALPHA_MONTH/A3 = EDIT(LOGIN_MONTH);
COMPUTE MAXCURUSER/D3=LCOUNTER;
BY USERNAME
BY SORT_DATE NOPRINT
BY LOG_STATE NOPRINT
ON TABLE HOLD AS SORTED_LOGS1
END
-*
-*
TABLE FILE SORTED_LOGS1
SUM MAX.LCOUNTER AS "MAX_LCOUNTER"
SUM MAX.LCOUNTER AS "MAX_MCOUNTER"
BY USERNAME
BY SORT_DATE NOPRINT
BY LOG_STATE NOPRINT
PRINT
LOGIN_DATE
LOGIN_MONTH
LOGIN_YEAR
LOGIN_DAY
LOG_STATE
SORT_DATE
OS_USERNAME
USERNAME
ALPHA_MONTH
FULL_MONTH
BY USERNAME
BY SORT_DATE NOPRINT
BY LOG_STATE NOPRINT
ON TABLE HOLD AS SORTED_LOGS
END
-*
GRAPH FILE SORTED_LOGS
-*
HEADING
"Project Reporting"
"Max Value:-*
SUM
MAX_LCOUNTER AS 'Concurrent Users'
ACROSS LOGIN_DAY COLUMNS 1 AND 2 AND 3 AND 4 AND 5 AND 6 AND 7 AND 8 AND 9 AND 10 AND 11 AND 12 AND 13 AND 14 AND 15 AND 16 AND 17 AND 18 AND 19 AND 20 AND 21 AND 22 AND 23 AND 24 AND 25 AND 26 AND 27 AND 28 AND 29 AND 30 AND 31
-*
ON GRAPH SET LOOKGRAPH LINE
END
-EXIT
-*
-*
The Issue I'm having is that the max_lcounter in the heading is not getting off the correct highest value that the graph is displaying. Any ideas as to why? Also how I could check it and modify it to give me the correct max value for the graph.

Thanks



Production & Development: WebFocus 7.6.4
February 12, 2009, 05:16 PM
j.gross
Please use the < / > code tags when posting code, esp when it contains <'s.

TABLE FILE SORTED_LOGS1
SUM MAX.LCOUNTER AS "MAX_LCOUNTER"   *** Use single quotes here, and SET ASNAMES=ON as shown below.

SUM MAX.LCOUNTER AS "MAX_MCOUNTER"   *** ditto
BY SORT_DATE 

*** drop the PRINT section, Graph needs just one record per date (with max pre-computed).

ON TABLE SET ASNAMES ON  *** 
ON TABLE HOLD AS LOG_SUMMARY
END

GRAPH FILE LOG_SUMMARY
HEADING
"Project Reporting"
"Max Value:<MAX_LCOUNTER"   ***  You need to reference MAX_LCOUNTER here for the global max, and MAX_MCOUNTER later for the daily max.  
                            ***  My recollection is that a tag like this defaults to the SUM value; you may have to code <FST.MAX_LCOUNTER to avoid summation.
SUM
MAX_MCOUNTER AS 'Concurrent Users'   *** use MAX_MCOUNTER here, as noted above
ACROSS LOGIN_DAY
COLUMNS 1 AND 2 AND 3 AND 4 AND 5 AND 6 AND 7 AND 8 AND 9 AND 10 AND 11
AND 12 AND 13 AND 14 AND 15 AND 16 AND 17 AND 18 AND 19 AND 20 AND 21
AND 22 AND 23 AND 24 AND 25 AND 26 AND 27 AND 28 AND 29 AND 30 AND 31
-*
ON GRAPH SET LOOKGRAPH LINE
END

February 13, 2009, 11:23 AM
Mayor
Okay j.gross I understand. And thank you both!!



Production & Development: WebFocus 7.6.4