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'm trying to count the number of distinct orders I get in this result set, but I think it's counting the number of lines, not the number of orders.
TABLE FILE SHIP2LIST
-*BY 'HOME_BR' AS 'BRANCH'
-*ON TABLE HOLD AS USXTRACT FORMAT FOCUS INDEX 'DIVISION' 'J1.PRODUCTS_US.PROD_CAT' 'J1.PRODUCTS_US.BRAND' 'J0.SALES_CURR_PREV_FY_US.GL_YR_MONTH'
SUM
'CNT.DST.J0.SALES_CURR_PREV_FY_US.ORDER_NUM' WITHIN TABLE
UNITS_PURCH AS 'U_PURCHASED'
'J0.SALES_CURR_PREV_FY_US.PURCH_DOLLARS' AS 'P_DOLLARS'
UNITS_RETURNED AS 'U_RETURNED'
'J0.SALES_CURR_PREV_FY_US.RETURN_DOLLARS' AS 'R_DOLLARS'
'J0.SALES_CURR_PREV_FY_US.GP_DOLLARS' AS 'GP_DOLLARS'
BY 'SHIP2LIST.SEG01.DIVISION' AS 'DIVISION'
BY 'J0.SALES_CURR_PREV_FY_US.GL_DT_FISCAL_YEAR' AS 'FYEAR'
BY 'J0.SALES_CURR_PREV_FY_US.GL_DT_FISCAL_QUARTER' AS 'FQTR'
BY 'J0.SALES_CURR_PREV_FY_US.GL_DT_FISCAL_PERIOD' AS 'FPER'
BY 'J0.SALES_CURR_PREV_FY_US.GL_YR_MONTH' AS 'YR_MO'
BY 'J0.SALES_CURR_PREV_FY_US.ORDER_METHOD' AS 'ORD_METH'
BY 'SHIP2LIST.SEG01.REGIONAL_MGR_ID' AS 'REG_MGR'
BY 'J0.SALES_CURR_PREV_FY_US.SALES_MGR_ID' AS 'SALES_MGR'
BY 'J0.SALES_CURR_PREV_FY_US.PR_BR' AS 'BRANCH'
BY 'SHIP2LIST.SEG01.BRANCH_ABBREV' AS 'BRANCH_NAME'
BY 'J0.SALES_CURR_PREV_FY_US.ORDER_NUM'
...MORE BY FIELDS...
.
.
.
I'm trying to build a summarized table that I can use in a dashboard environment and then I can do calculations for % of orders. I've tried a couple different scenarios and none seem to be working.
I don't actually need the ORDER_NUM to be a part of the final summarized table - I just have it in this part of the procedure to be able to count it. All I ultimately need is the # of orders.
Any help is greatly appreciated.
JeraleeThis message has been edited. Last edited by: Kerry,
WebFOCUS 7.7.03 Linux / Universe Db HTML/PDF/EXCEL/HTML Active
SUM 'CNT.DST.J0.SALES_CURR_PREV_FY_US.ORDER_NUM' BY 'SHIP2LIST.SEG01.DIVISION' AS 'DIVISION' SUM 'CNT.DST.J0.SALES_CURR_PREV_FY_US.ORDER_NUM' WITHIN TABLE UNITS_PURCH AS 'U_PURCHASED' 'J0.SALES_CURR_PREV_FY_US.PURCH_DOLLARS' AS 'P_DOLLARS' UNITS_RETURNED AS 'U_RETURNED' 'J0.SALES_CURR_PREV_FY_US.RETURN_DOLLARS' AS 'R_DOLLARS' 'J0.SALES_CURR_PREV_FY_US.GP_DOLLARS' AS 'GP_DOLLARS' BY 'SHIP2LIST.SEG01.DIVISION' AS 'DIVISION' BY 'J0.SALES_CURR_PREV_FY_US.GL_DT_FISCAL_YEAR' AS 'FYEAR' BY 'J0.SALES_CURR_PREV_FY_US.GL_DT_FISCAL_QUARTER' AS 'FQTR' BY 'J0.SALES_CURR_PREV_FY_US.GL_DT_FISCAL_PERIOD' AS 'FPER' BY 'J0.SALES_CURR_PREV_FY_US.GL_YR_MONTH' AS 'YR_MO' BY 'J0.SALES_CURR_PREV_FY_US.ORDER_METHOD' AS 'ORD_METH' BY 'SHIP2LIST.SEG01.REGIONAL_MGR_ID' aS 'REG_MGR' BY 'J0.SALES_CURR_PREV_FY_US.SALES_MGR_ID' AS 'SALES_MGR' BY 'J0.SALES_CURR_PREV_FY_US.PR_BR' AS 'BRANCH' BY 'SHIP2LIST.SEG01.BRANCH_ABBREV' AS 'BRANCH_NAME' BY 'J0.SALES_CURR_PREV_FY_US.ORDER_NUM'
SUM UNITS_PURCH AS 'U_PURCHASED' 'J0.SALES_CURR_PREV_FY_US.PURCH_DOLLARS' AS 'P_DOLLARS' UNITS_RETURNED AS 'U_RETURNED' 'J0.SALES_CURR_PREV_FY_US.RETURN_DOLLARS' AS 'R_DOLLARS' 'J0.SALES_CURR_PREV_FY_US.GP_DOLLARS' AS 'GP_DOLLARS' BY 'SHIP2LIST.SEG01.DIVISION' AS 'DIVISION' BY 'J0.SALES_CURR_PREV_FY_US.GL_DT_FISCAL_YEAR' AS 'FYEAR' BY 'J0.SALES_CURR_PREV_FY_US.GL_DT_FISCAL_QUARTER' AS 'FQTR' BY 'J0.SALES_CURR_PREV_FY_US.GL_DT_FISCAL_PERIOD' AS 'FPER' BY 'J0.SALES_CURR_PREV_FY_US.GL_YR_MONTH' AS 'YR_MO' BY 'J0.SALES_CURR_PREV_FY_US.ORDER_METHOD' AS 'ORD_METH' BY 'SHIP2LIST.SEG01.REGIONAL_MGR_ID' aS 'REG_MGR' BY 'J0.SALES_CURR_PREV_FY_US.SALES_MGR_ID' AS 'SALES_MGR' BY 'J0.SALES_CURR_PREV_FY_US.PR_BR' AS 'BRANCH' BY 'SHIP2LIST.SEG01.BRANCH_ABBREV' AS 'BRANCH_NAME' BY 'J0.SALES_CURR_PREV_FY_US.ORDER_NUM'
(FOC1867) DST OPERATOR MUST BE AT THE LOWEST LEVEL OF AGGREGATION
So, I'm assuming that this means it wants it within the second SUM? If so, then what would I put in the first SUM? The other fields I am aggregating? I'll try that..
WebFOCUS 7.7.03 Linux / Universe Db HTML/PDF/EXCEL/HTML Active
Again, I don't go through everyone's code "exactly".
Take out your last sort:
BY 'J0.SALES_CURR_PREV_FY_US.ORDER_NUM'
Actually, try this:
TABLE FILE SHIP2LIST
SUM
'CNT.DST.J0.SALES_CURR_PREV_FY_US.ORDER_NUM'
UNITS_PURCH AS 'U_PURCHASED'
'J0.SALES_CURR_PREV_FY_US.PURCH_DOLLARS' AS 'P_DOLLARS'
UNITS_RETURNED AS 'U_RETURNED'
'J0.SALES_CURR_PREV_FY_US.RETURN_DOLLARS' AS 'R_DOLLARS'
'J0.SALES_CURR_PREV_FY_US.GP_DOLLARS' AS 'GP_DOLLARS'
BY 'J0.SALES_CURR_PREV_FY_US.GL_DT_FISCAL_YEAR' AS 'FYEAR'
BY 'J0.SALES_CURR_PREV_FY_US.GL_DT_FISCAL_QUARTER' AS 'FQTR'
BY 'J0.SALES_CURR_PREV_FY_US.GL_DT_FISCAL_PERIOD' AS 'FPER'
BY 'J0.SALES_CURR_PREV_FY_US.GL_YR_MONTH' AS 'YR_MO'
BY 'J0.SALES_CURR_PREV_FY_US.ORDER_METHOD' AS 'ORD_METH'
BY 'SHIP2LIST.SEG01.REGIONAL_MGR_ID' aS 'REG_MGR'
BY 'J0.SALES_CURR_PREV_FY_US.SALES_MGR_ID' AS 'SALES_MGR'
BY 'J0.SALES_CURR_PREV_FY_US.PR_BR' AS 'BRANCH'
BY 'SHIP2LIST.SEG01.BRANCH_ABBREV' AS 'BRANCH_NAME
That's almost exactly where I started, but wihtout the WITHIN. I'm getting results but its still giving me a 1 on every line, even though they are on the same order.
As always - thank you for your patience with me!
WebFOCUS 7.7.03 Linux / Universe Db HTML/PDF/EXCEL/HTML Active
I am confused by your request. I would assume order number to be be unique for every order. Therefore a count of distinct order numbers from the TABLE would in fact be a count of the number of records in the table. No?
For example, in this query against the GGSALES sample table, field SEQ_NO is unique for every record. So the count of distinct SEQ_NO WITHIN TABLE will always be the same number, no matter which BY fields are used.
TABLE FILE GGSALES
SUM
CNT.DST.SEQ_NO WITHIN TABLE
UNITS
DOLLARS
BY REGION
BY ST
BY CATEGORY
BY PCD
BY PRODUCT
END
WebFOCUS 7.7.05
Posts: 1213 | Location: Seattle, Washington - USA | Registered: October 22, 2007
Actually there are multiple records per order because the data stores each line number separately. Therefore, I need to count each order number only once.
I thought this would be something easy to get but it's turning out to be more confusing than I expected.
Thank you!
WebFOCUS 7.7.03 Linux / Universe Db HTML/PDF/EXCEL/HTML Active
Based on your sample output above, it appears you want the distinct count to appear for only the first record in a "set". You should use that "set" value to define your WITHIN clause for the CNT.DST. operator. Then you can use a COMPUTE to limit the resulting counts to the first record in each set. For example:
TABLE FILE GGSALES
SUM
CNT.DST.PCD/I5 WITHIN REGION
COMPUTE CNT_DST_PCD/I5C = IF (REGION NE LAST REGION) THEN CNT.DST.PCD ELSE 0 ;
UNITS
DOLLARS
BY REGION
BY ST
BY CATEGORY
BY PRODUCT
END
WebFOCUS 7.7.05
Posts: 1213 | Location: Seattle, Washington - USA | Registered: October 22, 2007