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.
Hi, I want to calculate the percentage of patients whose ORDELAY is Less than equal to Zero V/S Total number of Patients. I'm using below code. My count are coming correct, but my percentage is not correct. Please advice.
DEFINE FILE HOLDA COUNTZERO/I4 = IF ORDELAY LE 0 THEN COUNTZERO + 1; COUNTTOT /I4 = IF (ORDELAY GT 0 OR ORDELAY LE 0) THEN COUNTTOT + 1; END
TABLE FILE HOLDA PRINT SURGEON SPECIALTY_CODE SVC_DEPT FULL_NAME SCHEDDATEYYMD STIME ITIME PATIENT_NAME ORDELAY AS 'Minutes between,Shcedule and Incision Start' COUNTZERO NOPRINT COUNTTOT NOPRINT BY SVC_DEPT BY ORDELAY NOPRINT ON TABLE RECAP DIFF4849/D11.2 = (COUNTZERO*100)/COUNTTOT; ON TABLE SUBFOOT " " "TOTAL PERCENTAGE OF TIME DIFFERENCE LE 0 = "TOTAL NUMBER OF PATIENTS WITH TIME DIFF LE 0 = "TOTAL NUMBER OF PATIENTS = ON TABLE PCHOLD FORMAT EXL2K END
I'm not an expert but I think you should initatialize your values in your define before you start your count and you should use sum instead of a print in your table file. I have played around with the car file to create an example that may help you or at least get your thoughts flowing ...
DEFINE FILE CAR
MYCOUNT/I2= 0;
COUNTZERO/I2 = IF (SEATS LE 2 AND COUNTRY EQ 'ENGLAND') THEN MYCOUNT+1 ELSE 0;
END
TABLE FILE CAR
SUM
COUNTZERO
CNT.SEATS AS 'TTLCOUNT'
WHERE COUNTRY EQ 'ENGLAND';
ON TABLE SET ASNAMES ON
ON TABLE HOLD AS MYFILE
END
TABLE FILE MYFILE
SUM
COUNTZERO
TTLCOUNT
COMPUTE PERCENT/D12.2 = COUNTZERO/TTLCOUNT;
END
Hope this helps ...
PROD: WebFOCUS 7.1.0 on Linux/Tomcat 5.5.12 (standalone)/Informix on AIX TEST: WebFOCUS 7.1.3 on Linux/Tomcat 5.5.16 (standalone)/Informix on AIX
Posts: 53 | Location: Montreal,Quebec,Canada | Registered: February 13, 2006
Manish You could also do a multi-verb request to calculate Total # of patients and # of patients whose ORDELAY LE 0. Something like:
TABLE FILE EMPDATA SUM SALARY AS GTOT SUM SALARY AS SUBTOT BY DIV SUM SALARY COMPUTE PERC1/D12.2% = ( SALARY * 100 ) / C2; COMPUTE PERC2/D12.2% = ( SALARY * 100 ) / C1; BY DIV BY DEPT END
where C2 is SUBTOT and C1 is GTOT. Instead of Summing up SALARY, you would use a variable and use it with SUM.
Hope this helps.
Rock On! Syed
Using WF 7.1.7/Dev Studio
Posts: 189 | Location: Boston, MA | Registered: July 12, 2005
Thanks for you help. But I'm not able to getting the expected result. As per my requirement, I've to print all the patient account and at the end I've to print the total percentage as subfoot. I'm not able to use Compute on Subfoot.
First off, the tags in your subfoot don't show up (the <... is interpretted as HTML); use [ code ] formatting when posting code.
What you had is:
DEFINE FILE HOLDA
COUNTZERO/I4 = IF ORDELAY LE 0 THEN COUNTZERO + 1;
COUNTTOT /I4 = IF (ORDELAY GT 0 OR ORDELAY LE 0) THEN COUNTTOT + 1;
END
TABLE FILE HOLDA
PRINT
SURGEON etc.
COUNTZERO NOPRINT
COUNTTOT NOPRINT
BY SVC_DEPT
BY ORDELAY NOPRINT
ON TABLE RECAP DIFF4849/D11.2 = (COUNTZERO*100)/COUNTTOT;
ON TABLE SUBFOOT
" "
"TOTAL PERCENTAGE OF TIME DIFFERENCE LE 0 = <DIFF4849"
"TOTAL NUMBER OF PATIENTS WITH TIME DIFF LE 0 = <COUNTZERO"
"TOTAL NUMBER OF PATIENTS = <COUNTTOT"
ON TABLE PCHOLD FORMAT EXL2K
END
The problem is, you are printing rather than summing the two defined counters; that leaves unclear what values of the counters will enter into the recap calculation. (If you take off the NOPRINT and add a COMPUTE with the same formula, you may be able to shed light on what values actually contribute to the recap in the present form)
Try promoting the counters to an overall SUM:
TABLE FILE HOLDA
SUM
COUNTZERO NOPRINT
COUNTTOT NOPRINT
COMPUTE DIFF4849/D11.2 = (COUNTZERO*100)/COUNTTOT; NOPRINT
PRINT
SURGEON etc.
BY SVC_DEPT
BY ORDELAY NOPRINT
ON TABLE SUBFOOT ...
Third, I dislike Defines using IF ... THEN ... without specifying ELSE ...
The behavior one expects is ELSE "unchanged" but AFAIK that's undocumented. I tend to avoid the IF construct, coding it as:
COUNTZERO/I4 = LAST COOUNTZERO + (ORDELAY LE 0);
This message has been edited. Last edited by: j.gross,
- Jack Gross WF through 8.1.05
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005
The behavior one expects is ELSE "unchanged" but AFAIK that's undocumented.
Sorry Jack, that is documented
Syntax: How to Write a Conditional Expression IF expression1 THEN expression2 [ELSE expression3] where:
expression1 Is the expression that is evaluated to determine whether the field is assigned the value of expression2 or of expression3.
expression2 Is an expression that results in a format compatible with the format assigned to the field. It may be a conditional expression, in which case you must enclose it in parentheses.
expression3 Is an expression that results in a format compatible with the format assigned to the field. Enclosure of the expression in parentheses is optional. ELSE Is optional, along with expression3. However, if you do not specify an ELSE condition and the IF condition is not met, the value is taken from the last evaluated condition.
Note that the final sorted report may display mixed values. This depends on whether a DEFINE or a COMPUTE is used, and if a data record is evaluated before or after aggregation.