Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.

Join the TIBCO Community
TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.

  • From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
  • Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
  • Request access to the private WebFOCUS User Group (login required) to network with fellow members.

Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     SUM and Field using WHERE clause

Read-Only Read-Only Topic
Go
Search
Notify
Tools
SUM and Field using WHERE clause
 Login/Join
 
Gold member
posted
I'm sure I've seen a way to do this, but I cannot remember. I would like to average a field only where that field above a certain value. Something like this:
TABLE FILE SPORTS
SUM
AVE.SCORE AS 'OVERALL AVERAGE'
AVE.SCORE AS 'REAL AVG' (WHERE SCORE GT 15)
BY MONTH
WHERE SPORT EQ 'FOOTBALL';
ON TABLE HOLD AS H1
END

It's the 2nd average score that I can't seem to figure out. I am not creating any subtotals here.


WF (App Studio) 8.2.01m / Windows
Mainframe FOCUS 8
 
Posts: 93 | Registered: February 20, 2008Report This Post
Expert
posted Hide Post
Try this:

DEFINE FILE SPORTS
SCORE15/I8=IF SCORE GT 15 THEN SCORE ELSE 0;
END
TABLE FILE SPORTS
SUM
AVE.SCORE AS 'OVERALL AVERAGE'
AVE.SCORE15 AS 'REAL AVG' 
BY MONTH
WHERE SPORT EQ 'FOOTBALL';
ON TABLE HOLD AS H1
END


I haven't test this but it might give you some ideas. However, it might affect the average as it would average in the zeroes.

You might have to also count the number that are not zero and use that as the denominator in a COMPUTE.

Play around with it and see what you come up with.


Ginny
---------------------------------
Prod: WF 7.7.01 Dev: WF 7.6.9-11
Admin, MRE,self-service; adapters: Teradata, DB2, Oracle, SQL Server, Essbase, ESRI, FlexEnable, Google
 
Posts: 2723 | Location: Ann Arbor, MI | Registered: April 05, 2006Report This Post
Virtuoso
posted Hide Post
Make use of MISSING. Define:
over_15_score/i5 missing on=
if score gt 15 then score
else missing;

and report the everages:
ave.score
ave.over_15-score


- Jack Gross
WF through 8.1.05
 
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005Report This Post
Virtuoso
posted Hide Post
adding to Ginny's code:
DEFINE FILE SPORTS
SCORE15/I8 MISSING ON=IF SCORE GT 15 THEN SCORE ELSE MISSING;
END
TABLE FILE SPORTS
SUM
AVE.SCORE AS 'OVERALL AVERAGE'
AVE.SCORE15 AS 'REAL AVG'
BY MONTH
WHERE SPORT EQ 'FOOTBALL';
ON TABLE HOLD AS H1
END

Then you would only get the average of those that had values and ignore the rest.


Regards,

Darin



In FOCUS since 1991
WF Server: 7.7.04 on Linux and Z/OS, ReportCaster, Self-Service, MRE, Java, Flex
Data: DB2/UDB, Adabas, SQL Server Output: HTML,PDF,EXL2K/07, PS, AHTML, Flex
WF Client: 77 on Linux w/Tomcat
 
Posts: 2298 | Location: Salt Lake City, Utah | Registered: February 02, 2007Report This Post
Gold member
posted Hide Post
Thank you to all. Using ...ELSE MISSING did the trick. Did not put the MISSIN=ON in the first part of the define originally, so thanks to Darin Lee.


WF (App Studio) 8.2.01m / Windows
Mainframe FOCUS 8
 
Posts: 93 | Registered: February 20, 2008Report This Post
Virtuoso
posted Hide Post
By default, when you do a DEFINE it will always have either a value as determined by the expression or a blank for alpha or 0 for numeric. The addition of the MISSING ON on the left side of the expression allows a DEFINEd field to be null or missing. Glad you found what you needed. Ya'll come back soon for more(another word I learned at Summit this year!)


Regards,

Darin



In FOCUS since 1991
WF Server: 7.7.04 on Linux and Z/OS, ReportCaster, Self-Service, MRE, Java, Flex
Data: DB2/UDB, Adabas, SQL Server Output: HTML,PDF,EXL2K/07, PS, AHTML, Flex
WF Client: 77 on Linux w/Tomcat
 
Posts: 2298 | Location: Salt Lake City, Utah | Registered: February 02, 2007Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     SUM and Field using WHERE clause

Copyright © 1996-2020 Information Builders