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.
I am trying to create a column of data that has the difference between numeric format field value on the current record to the one on the previous record with the code below.
The PRVDELTA define correcly returns the previous record's value. However, the PRVDELTA2 define does not return previous record's value that corresponds with PRVDELTA.
Am I using the LAST Function correctly?
TABLE FILE BASELINE2
SUM
CT_DAYS AS 'CT_DAYS'
BY SRT_MONTH AS 'SRT_MONTH'
ON TABLE HOLD AS 'BASELINE3'
END
DEFINE FILE BASELINE3
PRVDELTA/YYMD= IF SRT_MONTH EQ LAST SRT_MONTH THEN SRT_MONTH ELSE LAST SRT_MONTH;
PRVDELTA2/I8= IF SRT_MONTH EQ LAST SRT_MONTH THEN CT_DAYS ELSE LAST CT_DAYS;
END
TABLE FILE BASELINE3
PRINT
SRT_MONTH AS 'Month'
CT_DAYS AS 'Cycle Days'
PRVDELTA AS 'Previous Month'
PRVDELTA2 AS 'Previous Month Cycle Days'
BY SRT_MONTH NOPRINT
ON TABLE SET STYLE *
TYPE=DATA, COLUMN=N2, BACKCOLOR=BLUE, WHEN=CT_DAYS LT 14,$
TYPE=DATA, COLUMN=N2, BACKCOLOR=LIME, WHEN=CT_DAYS LT 19,$
TYPE=DATA, COLUMN=N2, BACKCOLOR=YELLOW, WHEN=CT_DAYS LT 24,$
TYPE=DATA, COLUMN=N2, BACKCOLOR=RED, WHEN=CT_DAYS GT 25,$
ENDSTYLE
ON TABLE SET HTMLCSS ON
ON TABLE SET PAGE-NUM OFF
ON TABLE NOTOTAL
END
-EXIT
This message has been edited. Last edited by: Kerry,
DEFINE FILE BASELINE3
PRVDELTA/YYMD= IF SRT_MONTH EQ LAST SRT_MONTH THEN PRVDELTA ELSE LAST SRT_MONTH;
PRVDELTA2/I8= IF SRT_MONTH EQ LAST SRT_MONTH THEN PRVDELTA2 ELSE LAST CT_DAYS;
END
PRVDELTA/YYMD= IF SRT_MONTH NE LAST SRT_MONTH THEN LAST SRT_MONTH ELSE PRVDELTA;
PRVDELTA2/I8= IF SRT_MONTH NE LAST SRT_MONTH THEN LAST CT_DAYS ELSE PRVDELTA2;
Try this. I always do my NE logic first as it makes more sense to me to figure out what I want to do on the sort break.
I suspect that the data in BASELINE3 is not as you are expecting, reason unknown. Your use of LAST is fine if the data coming in is correct. Try
TABLE FILE BASELINE3
SUM
SRT_MONTH AS 'Month'
CT_DAYS AS 'Cycle Days'
COMPUTE
PRVDELTA/YYMD = IF SRT_MONTH EQ LAST SRT_MONTH THEN SRT_MONTH ELSE LAST SRT_MONTH;
AS 'Previous Month'
COMPUTE
PRVDELTA2/I8 = IF SRT_MONTH EQ LAST SRT_MONTH THEN CT_DAYS ELSE LAST CT_DAYS;
AS 'Previous Month Cycle Days'
BY SRT_MONTH NOPRINT
END
and see what happens.
Alan. WF 7.705/8.007
Posts: 1451 | Location: Portugal | Registered: February 07, 2007
Did you use the defines in my last post. I tested those with your data and got the right answers.
It appears to me that your data is correct. It must be sorted by SRT_MONTH and there is only one row per month. That is what I determine from your code.
I greatly appreciate your help. I used your defines. It appears to be working correctly for the previous month column, but not the cycle days column.
For example, on the results I got above, the February record correctly shows that the previous month is January, but on the February row, the Previous Month (January) cycle days do not match the january record from above.
What would cause LAST to work for one field, but not the other? Field format? Sorting?
The problem was not with the DEFINE itself, or the compute.
The problem was being caused by the PRVDELTA2 field formatting being I8, but the CT_DAYS was formatted as D8S. Once I made PRVDELTA2 to a D8S format, it fixed the problem.