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.
Hopefully this is an easy request. I have done some searching and found other posts relating to Column totals, but not Row totals with Across.
I have a table that list 3 columns:
MINS - Number of minutes C_HOURS - Computed field, performing an IMOD by 60 on MINS to retrieve the number of whole hours C_MINS - Computed field, performing an INT on the remainder.
Here is my table and results I am seeing:
TABLE FILE TEST SUM C_DIFF AS 'MINS' COMPUTE C_HOURS/I5=INT(C_DIFF/60); COMPUTE C_MINS/I5=IMOD(C_DIFF,60,'I5');
BY ID AS ' ' ACROSS DAY_NO AS ' ' ON TABLE ROW-TOTAL AS 'TOTAL' ON TABLE NOTOTAL END -RUN
So for the first day (number 3), the total minutes were 570m. C_HOURS and C_MINS are correct at 9hr 30m. For the second day (number 4), the total minutes were 630m. C_HOURS and C_MINS are correct at 10hr 30m. etc ect
However when we come to the ROW TOTAL the 3 columns are totalled after the Computes have taken place. This gives me the incorrect result for 1830 minutes of 29hr 90m. I need it to read 30hr 30m.
I found the following document, which suggests to use COMPUTES and SUMMARIZE but I cannot get this to work with ROW-TOTALS and ACROSS.
Cheers This message has been edited. Last edited by: mark66,
WebFocus 765. iSeries v5r4
Posts: 175 | Location: England | Registered: April 11, 2006
I have recreated your dilemma using the CAR file, so hopefully others can take a crack at it too:
TABLE FILE CAR
SUM
COMPUTE XYZ/I5 = WHEELBASE;
COMPUTE C_HOURS/I5=INT(XYZ/10);
COMPUTE C_MINS/I5=IMOD(XYZ,10,'I5');
ACROSS SEATS
BY COUNTRY
ON TABLE ROW-TOTAL AS 'TOTAL'
ON TABLE NOTOTAL
END
The total values for W Germany are not showing up properly. C_HOURS is showing as 71, but should be 72, and C_MINS is showing as 11, and should be 1.
I'll let you know if I figure it out.
Sean
------------------------------------------------------------------------ PROD: WebFOCUS 7.6.2 on Unix AIX/Tomcat/Servlet Mode TEST: WebFOCUS 7.6.2 on Unix AIX/Tomcat/Servlet Mode
Posts: 210 | Location: Ottawa | Registered: November 03, 2005
I modified my code sample to work in 7.6.2, but it does not work in 5.2.8. So I don't know if this will work for you in 5.3.5 or not:
TABLE FILE CAR
SUM
COMPUTE XYZ/I5 = WHEELBASE;
COMPUTE C_HOURS/I5=INT(XYZ/10);
COMPUTE C_MINS/I5=IMOD(XYZ,10,'I5');
ACROSS SEATS AND RECOMPUTE AS 'Row Totals'
BY COUNTRY
ON TABLE NOTOTAL
END
Sean
------------------------------------------------------------------------ PROD: WebFOCUS 7.6.2 on Unix AIX/Tomcat/Servlet Mode TEST: WebFOCUS 7.6.2 on Unix AIX/Tomcat/Servlet Mode
Posts: 210 | Location: Ottawa | Registered: November 03, 2005
You could try the following code (which works for every release as far as I know):
TABLE FILE TEST
SUM C_DIFF AS 'MINS'
COMPUTE C_HOURS/I5=INT(C_DIFF/60);
COMPUTE C_MINS/I5=IMOD(C_DIFF,60,'I5');
BY ID AS ' '
ACROSS DAY_NO AS ' '
COMPUTE TMIN/I5 = C1 + C4 + C7 + C10 + C13 + C16; AS 'TOTAL'
COMPUTE CHRS/I5 = INT(TMIN/60); AS ''
COMPUTE CMIN/I5 = IMOD(TMIN,60,'I5'); AS ''
ON TABLE NOTOTAL
END
Only there are two things to be aware of with this approach: 1. titles of the computes. Can't seem to find a way around that. 2. you never knoe up front how many across values there will be (hence the c1+c4+c7+ etc.). Maybe you can make this dynamic.
Hope this helps.
GamP
- Using AS 8.2.01 on Windows 10 - IE11.
in Focus since 1988
Posts: 1961 | Location: Netherlands | Registered: September 25, 2007
DEFINE FILE CAR
W0/I6=WHEELBASE;
W1/I6=WHEELBASE;
END
TABLE FILE CAR
SUM W0 NOPRINT
BY COUNTRY
SUM
COMPUTE C_DIFF/I5 = W1;
COMPUTE C_HOURS/I5=INT(C_DIFF/60);
COMPUTE C_MINS/I5=IMOD(C_DIFF,60,'I5');
BY COUNTRY
ACROSS SEATS
COMPUTE T_DIFF/I6=W0;
T_HOURS/I5=INT(T_DIFF/60);
T_MINS/I5=IMOD(T_DIFF,60,'I5');
ON TABLE NOTOTAL
END
With this coding you do not have any problems with the number of across ACROSS values.
Daniel In Focus since 1982 wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF
Posts: 1980 | Location: Tel Aviv, Israel | Registered: March 23, 2006
Thanks again for everyones help and time spent looking at this for me, I really appreciate it!
GamP, as the number of across values is always changing, I really wasn't sure if I could use this approach, eg to make the code clever enough to work out the calculation depending on the number of columns.
Danny-SRL, unfortunately I could not get your solution to work either. It just gave me the total time for the first day?
For the time being (until we go to v7) I have found a relatively simple workaround. I first build a basic hold file, summarising the total time worked in the desired format by user. I then join to this file by user ID and just use the total time as a 3rd BY field:
The total time logged isn't on the right hand side as you would expect it to be, but at least the information is there!
If I could ask one last question....
How can I suppress drill down links if there is no data for that cell? Currently I have a '.' with a hyper link in. I would prefer if I had nothing.
CheersThis message has been edited. Last edited by: mark66,
WebFocus 765. iSeries v5r4
Posts: 175 | Location: England | Registered: April 11, 2006
Ok, I have managed to get your code to work with my example!
However, I am struggling to understand exactly how it is working. The code looks different to anything I have worked with in my limited experience, for example:
Having two SUM statements Multiple COMPUTE statements (T_DIFF, T_HOUR, T_MINS) yet with only one COMPUTE coded?
I also find that I am unable to hide (NOPRINT) the T_DIFF column. My only option is to delete it? Ideally I need to reformat T_HOUR and T_MINS together to look like a proper time format HH:MM.
Thanks again for your help, ideally I would much prefer to use your method over my hold file workaround, but only if I can achieve the one total column in HH:MM.
Cheers
WebFocus 765. iSeries v5r4
Posts: 175 | Location: England | Registered: April 11, 2006
Mark, To answer your questions: The 2 SUM statements are called "multi-verb requests". This has always been one of the great fortes of Focus and Webfocus. You can find the documentation in the manual (see page 4-37 in the 7.6 creating reports manual). Concerning COMPUTE statements in a TABLE command, you can have any number of statements, one after the other, after a single COMPUTE. However if after a ';' you write NOPRINT then for the next computed statement you must code COMPUTE again. To display your hours in the HH:MM form you can use Tony's example. Regards
Daniel In Focus since 1982 wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF
Posts: 1980 | Location: Tel Aviv, Israel | Registered: March 23, 2006
The F2L is F2 with leading zeroes. It ensures that you do not get 00: 0 output!! The reason that you are getting 30:** is probably due to the format you are giving to W0 - change it to F5 for my example.
Using the code that I used above, but with Danny's set-up, try this -
APP FI MARK66 DISK MARK66.MAS (LRECL 80
-RUN
-WRITE MARK66
-WRITE MARK66 FILE=MARK66,SUFFIX=FOC
-WRITE MARK66 SEGNAME=SEG1
-WRITE MARK66 FIELD=ID, ,A4 ,A4 ,FIELDTYPE=I, $
-WRITE MARK66 FIELD=LOG_DATE, ,DMYY ,DMYY , $
-WRITE MARK66 FIELD=MINS, ,I4 ,I4 , $
-RUN
CREATE FILE MARK66
MODIFY FILE MARK66
FIXFORM ID/A4 LOG_DATE/A8 MINS/A4
DATA
ERV 031020070570
ERV 041020070630
ERV 051020070330
ERV 061020070300
FVM 031020070570
FVM 041020070930
FVM 051020070430
FVM 061020070400
ZPM 031020070770
ZPM 041020070730
ZPM 061020070700
END
-RUN
DEFINE FILE MARK66
MINS0/F5 = MINS;
MINS1/F5 = MINS;
END
TABLE FILE MARK66
SUM MINS0 NOPRINT
BY ID AS ''
SUM COMPUTE SUM_LOGGED/A8 = FTOA(INT(MINS1/60), '(F5)', 'A5')||':'||FTOA(IMOD(MINS1,60,'F2L'), '(F2L)', 'A2'); AS ''
BY ID AS ''
ACROSS LOG_DATE AS ''
-* RECOMPUTE AS 'Total'
COMPUTE TOT_LOGGED/A8 = FTOA(INT(MINS0/60), '(F5)', 'A5')||':'||FTOA(IMOD(MINS0,60,'F2L'), '(F2L)', 'A2'); AS 'Total'
ON TABLE NOTOTAL
ON TABLE SET HTMLCSS ON
ON TABLE SET PAGE-NUM NOLEAD
ON TABLE SET STYLE *
ENDSTYLE
END
-RUN
The reason that Danny had three fields and only one compute is that the compute is inferred in subsequent calcs. Not what I would recommend because it does make the code a little difficult to read by inexperienced WF coders - as you found yourself. And from a maintenance point of view that becomes important.
Note that the COMPUTE that Danny uses after the final verb (ACROSS) isn't preceded by a SUM or PRINT etc. and this actually performs the same as a RECOMPUTE would in 7.n (almost )
Good luck
T
In FOCUS since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2
WebFOCUS App Studio 8.2.06 standalone on Windows 10
Posts: 5694 | Location: United Kingdom | Registered: April 08, 2004
Danny, thanks for your explanation if the Multi_verb, I will look it up
Tony,
I have tried all combinations of formats, but I am still getting the ** in the minutes:
The only difference in my code and yours is MINS in the DEFINE. I am actually calculating MINS from the number of minutes in the End Time of each log minus the number of minutes in the Start Time of each log.
Without your full code and data it would be difficult to discern why you are getting the **.
However, using the same data as you in (yet again) the example I used above, but this time using a start and end time in HHMM format (as integer e.g. 08:00 am = 800 etc.), try this -
APP FI MARK66 DISK MARK66.MAS (LRECL 80
-RUN
-WRITE MARK66
-WRITE MARK66 FILE=MARK66,SUFFIX=FOC
-WRITE MARK66 SEGNAME=SEG1, SEGTYPE=S2, $
-WRITE MARK66 FIELD=ID, ,A4 ,A4 ,FIELDTYPE=I, $
-WRITE MARK66 FIELD=LOG_DATE, ,I4 ,I4 ,FIELDTYPE=I, $
-WRITE MARK66 FIELD=TBTIME, ,I4 ,I4 , $
-WRITE MARK66 FIELD=TETIME, ,I4 ,I4 , $
-RUN
CREATE FILE MARK66
MODIFY FILE MARK66
FIXFORM ID/A4 LOG_DATE/A4 TBTIME/A4 TETIME/A4
DATA
ERV 3 800 900
ERV 3 9001300
ERV 313001730
ERV 4 7001730
ERV 5 7001230
ERV 6 8301330
END
-RUN
DEFINE FILE MARK66
SMINS/F5=INT(TBTIME/100) * 60 + IMOD(TBTIME,100,'I5');
EMINS/F5=INT(TETIME/100) * 60 + IMOD(TETIME,100,'I5');
MINS1/F5 = EMINS - SMINS;
END
TABLE FILE MARK66
SUM COMPUTE MINS0/F5 = EMINS - SMINS; NOPRINT
BY ID AS ''
SUM COMPUTE SUM_LOGGED/A8 = FTOA(INT(MINS1/60), '(F5)', 'A5')||':'||FTOA(FMOD(MINS1,60,'F2L'), '(F2L)', 'A2'); AS ''
BY ID AS ''
ACROSS LOG_DATE AS ''
-* RECOMPUTE AS 'Total'
COMPUTE TOT_LOGGED/A8 = FTOA(INT(MINS0/60), '(F5)', 'A5')||':'||FTOA(FMOD(MINS0,60,'F2L'), '(F2L)', 'A2'); AS 'Total'
ON TABLE NOTOTAL
ON TABLE SET HTMLCSS ON
ON TABLE SET PAGE-NUM NOLEAD
ON TABLE SET STYLE *
ENDSTYLE
END
-RUN
Note the change from IMOD to FMOD.
Gives this -
3
4
5
6
Total
ERV
9:30
10:30
5:30
5:00
30:30
T
In FOCUS since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2
WebFOCUS App Studio 8.2.06 standalone on Windows 10
Posts: 5694 | Location: United Kingdom | Registered: April 08, 2004