Jump to content
The ibi Community has moved to a new platform: Please Sign In and choose Forgot Password to continue

Hello All! Im a first time poster and am fairly new to Webf...


Jeff Musselamn

Recommended Posts

Hello All! Im a first time poster and am fairly new to Webfocus, so hopefully Im providing enough information

Im trying to display the overall average of a field defined as a compute in a synonym. The code is more or less like this:

TABLE FILE myTable

SUM COMPUTE AVE.TOTAL_TOUCHES;

BY TOUCH_DATE_HOUR NOPRINT

WHERE TOUCH_DATE GE &THIS_WEEK;

ON TABLE SUBTOTAL AVE. TOTAL_TOUCHES AS 'AVE: '

END

 

 

ss.jpg181715 41.7 KB

 

With the above code, adding the AVE prefix to the SUBTOTAL LINE gives me the correct value, but adding it to the SUM COMPUTE line gives only the count from the individual hour.

My first question is why the AVE prefix isnt actually calculating the average

Ultimately I only want to get this overall average as a variable and use it in a custom HTML form, so my second question: whats the best way to go about isolating that number

Im using 8207 if that matters. Any help or a pointer to the correct documentation is very much appreciated!

Link to comment
Share on other sites

I experimented with this and it appears that taking the AVE. of a COMPUTE field doesnt do the averaging. I guess it would have to do with the internal order of processing.

Thinking about alternatives, perhaps one of these would be workable:

 

If it would work to have the COMPUTE in the synonym be a DEFINE, seems like the AVE. should work.

You could explicitly calculate your average:

COMPUTE TOTAL_TOUCHES; NOPRINT

COMPUTE AVETOUCH/I9 = TOTAL_TOUCHES / CNT.TOUCH_DATE_HOUR; AS 'Total Touches'

 

You could retain the touches detail data into a hold file and do the AVE. calculation from the hold file.

 

For capturing the number in a variable, you could code this:

TABLE FILE myTable

SUM

COMPUTE TOTAL_TOUCHES; NOPRINT

COMPUTE AVE_TOTAL_TOUCHES/I9 = TOTAL_TOUCHES / CNT.TOUCH_DATE_HOUR;

COMPUTE AVE_TOTAL_TOUCHES2/P9.1 = TOTAL_TOUCHES / CNT.TOUCH_DATE_HOUR;

ON TABLE HOLD AS touches

END

-RUN

-SET &AVE_TOTAL_TOUCHES = 0;

-SET &AVE_TOTAL_TOUCHES2 = 0;

-READFILE touches

 

-HTMLFORM BEGIN

<html>

Total Touches:

<br>!IBI.AMP.AVE_TOTAL_TOUCHES;

<br>!IBI.AMP.AVE_TOTAL_TOUCHES2;

</html>

-HTMLFORM END

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...