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     [SOLVED] Issue with Week function EOW to sum Dollars weekly

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] Issue with Week function EOW to sum Dollars weekly
 Login/Join
 
Gold member
posted
Week function EOW to sum Dollars weekly from Sunday to Saturday. I was trying to get the dollars to sum up for the start of the week to the end of the week based on my code BOW2 to EOW2. I thought if I sorted by EOW2 it would work. Instead it shows the EOW2 date an next to it I added the original date "BUDAT" and as you can see below my code ... my example shows the sort date (EOW2) of 2011/01/08 but 2011/01/08 is not included in my cumulative field I calculated called "RTOTAL"..I am not sure why??? here is my code & sample below:

DEFINE FILE GLPCA
XWEEK1/A8YYMD=BUDAT;
XWEEK2/YYMD=XWEEK1;
EXDATE1/YYMD = XWEEK2;
BOW1/YYMD = DATEMOV(EXDATE1, 'BOW');
EOW1/YYMD = DATEMOV(EXDATE1, 'EOW');
BOW2/YYMD = DATEADD(BOW1, 'DAY', -1);
EOW2/YYMD = DATEADD(EOW1, 'DAY', +1);
END
TABLE FILE GLPCA
SUM KSL
COMPUTE RTOTAL/D12C=IF MPLANT EQ LAST MPLANT THEN KSL+RTOTAL ELSE KSL;
BY MPLANT
BY EOW2
BY EXDATE1
END
-------------------
Here is the output:

PLANT EOW2 EXDATE1 KSL RTOTAL
B02 2011/01/08 2011/01/01 22.10 22
2011/01/02 28.41 51
2011/01/03 -393.86 -343
2011/01/04 7917.33 7,574
2011/01/05 19161.23 26,735
2011/01/06 -11897.47 14,838
2011/01/07 3165.86 18,004
2011/01/15 2011/01/08 442.00 18,446

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


8.0.9, Windows
excel / pdf
 
Posts: 89 | Registered: October 21, 2010Report This Post
Expert
posted Hide Post
COMPUTE RTOTAL/D12C=IF MPLANT EQ LAST MPLANT THEN KSL+RTOTAL ELSE KSL;
To use the LAST syntax, the data must be previously sorted in the correct order, i.e. GLPCA must already be sorted by MPLANT.

Please put your code and report within
[code]
[/code]
tags.


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
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Gold member
posted Hide Post
Francis,
The RTOTAL field calculates correctly....the problem is I need to sort the data by plant and the total for each week should be the cumulative total "RTOTAL" from each Sunday to Saturday...as you can see in my report under the code ...even though the endweek(EOW2) is correct that date is NOT included in the week...it's actually in the next week. My problem is how do I sum the dollars from Sunday to Saturday showing the valuse in the report by PLANT across WEEK.
thanks

DEFINE FILE GLPCA
XWEEK1/A8YYMD=BUDAT;
XWEEK2/YYMD=XWEEK1;
EXDATE1/YYMD = XWEEK2;
BOW1/YYMD = DATEMOV(EXDATE1, 'BOW');
EOW1/YYMD = DATEMOV(EXDATE1, 'EOW');
BOW2/YYMD = DATEADD(BOW1, 'DAY', -1);
EOW2/YYMD = DATEADD(EOW1, 'DAY', +1);
END
TABLE FILE GLPCA
SUM KSL
COMPUTE RTOTAL/D12C=IF MPLANT EQ LAST MPLANT THEN KSL+RTOTAL ELSE KSL;
BY MPLANT
BY EOW2
BY EXDATE1
END


REPORT :

PLANT EOW2         EXDATE1       KSL       RTOTAL 
B02  2011/01/08    2011/01/01   22.10         22 
                   2011/01/02   28.41         51 
                   2011/01/03  -393.86      -343 
                   2011/01/04  7917.33     7,574 
                   2011/01/05  19161.23   26,735 
                   2011/01/06  -11897.47  14,838 
                   2011/01/07  3165.86    18,004 
     2011/01/15    2011/01/08  442.00     18,446 



8.0.9, Windows
excel / pdf
 
Posts: 89 | Registered: October 21, 2010Report This Post
Platinum Member
posted Hide Post
Your code is performing as expected. If you print off the value of EOW1 you should be able to see what is happening.

WebFOCUS has calculated the EOW date for the 08/01/2011 as being the 14/01/2011, adding 1 to this date gives you the 15/01/2011 it doesn't move the EOW calculation in any way.

I believe you are supposed to be able to change which day is the start of the week using some combination of the following settings:

SET BUSDAY
SET WEEKFIRST

hopefully someone else who has done this will know the required settings for you.


WF 7.6.11
Output: HTML, PDF, Excel
 
Posts: 123 | Location: UK | Registered: October 09, 2003Report This Post
Gold member
posted Hide Post
quote:
SET BUSDAY
SET WEEKFIRST


Tewy,
I tried what you suggested....but still getting the same results.

Does anyone have an idea on how to do this??

thanks


8.0.9, Windows
excel / pdf
 
Posts: 89 | Registered: October 21, 2010Report This Post
Expert
posted Hide Post
In your DEFINE, the EOW function calculates the End of Week of a Saturday to be the next Friday, then you add one to get a Saturday, that's why the end of week for 2011/01/08 is 2011/01/15.

I'll try to come up with code to deal with this.


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
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Expert
posted Hide Post
Using a supplied sample database, here's a solution. If the difference in days between the Date and the normally calculated End-of-week is 6 (meaning the Date is a Saturday), use the Date as the End-of-week, else use the normally calculated End-of-week + 1 as the End-of-week.

DEFINE FILE CENTQA
EXDATE1/YYMD = PROBLEM_DATE;
EOW1/YYMD = DATEMOV(EXDATE1, 'EOW');
EOW2/YYMD = IF DATEDIF(EXDATE1, EOW1, 'D') EQ 6 THEN EXDATE1 ELSE DATEADD(EOW1, 'DAY', +1);
MPLANT/A3 = PLANT;
KSL/D10 = QTY_IN_STOCK;
END

TABLE FILE CENTQA
SUM
KSL
BY EOW2
BY EXDATE
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
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Gold member
posted Hide Post
Francis
Looks great !!
Thanks fo ryour help.
Matt


8.0.9, Windows
excel / pdf
 
Posts: 89 | Registered: October 21, 2010Report 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     [SOLVED] Issue with Week function EOW to sum Dollars weekly

Copyright © 1996-2020 Information Builders