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] Distinct count on a ROW Total

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[Solved] Distinct count on a ROW Total
 Login/Join
 
Platinum Member
posted
Hi,

I am trying to pivot and get the unique PartKey count and Sales$.
By Fields are Mfr and Type
Across is YearQtr

I can use count distinct and the Pivot is fine but struggling with ROW_TOTAL.
ROW-TOTAL shows some of distinct PARTKEY and NOT distinct PARTKEY.

Below is the dataset, current result and Expected result.

Not sure how to get the expected result.
Would prefer to do this in InfoAssist but open to other suggestions Smiler


Thanks









This message has been edited. Last edited by: Kathleen Butler,
 
Posts: 167 | Location: Montreal | Registered: September 23, 2014Report This Post
Expert
posted Hide Post
To achieve this you will have to handle the data twice, once to get your row totals and then the second to get your combined output.

Because you are using ACROSS, there will be some title issues, but I am sure there will be many suggestions on how you might achieve this.

As this is a situation that many can find an obstacle, here is some sample code using the data that you have shared. Note that the first report represents your current output, and the second is the one that you desire.

-* Start of data preparation
EX -LINES * EDAPUT MASTER,BMFILE,CV,MEM
FILE=BMFILE,SUFFIX=FOC
SEGNAME=SEG1
FIELD=MFR,      ,A1   ,A1   ,$
FIELD=YearQtr,  ,A7   ,A7   ,$
FIELD=Type,     ,A2   ,A2   ,$
FIELD=PartKey,  ,A10  ,A10  ,$
FIELD=SALES,    ,D12M ,D12  ,$
EDAPUT*
-RUN

CREATE FILE BMFILE
MODIFY FILE BMFILE
FREEFORM MFR YearQtr Type PartKey SALES
DATA
A,2015-01,1A,193,1192,$
A,2015-01,1A,1934,812,$
A,2015-01,1A,CAN00,66,$
A,2015-01,4D,CAN00,115,$
A,2015-01,4D,CAN00,1125,$
A,2015-01,1A,F06,1215,$
A,2015-02,1A,193,6556,$
A,2015-02,1A,CAN00,66,$
A,2015-02,4D,VGAS,140,$
A,2015-03,4D,1934,138,$
A,2015-03,4D,CAN,66,$
A,2015-03,3C,VJ13,640,$
A,2015-04,1A,193,3874,$
A,2015-04,1A,VJ13,1080,$
A,2015-04,2B,VJ13,558,$
B,2015-01,1A,F06,1215,$
B,2015-02,1A,193,6556,$
B,2015-02,4D,CAN,66,$
B,2015-03,3C,VJ13,64,$
B,2015-04,1A,193,38,$
B,2015-04,1A,193,64,$
END
-RUN
-* End of data preparation

SET PAGE = NOLEAD
SET ASNAMES = MIXED

TABLE FILE BMFILE
  SUM CNT.PartKey AS 'Count'
      SALES       AS 'Sum'
   BY MFR
   BY Type
ACROSS YearQtr AS ''
ON TABLE ROW-TOTAL AS 'Total'
END
-RUN

TABLE FILE BMFILE
  SUM CNT.DST.PartKey AS DSTPARTS
      SALES AS TOTSALES
   BY MFR
   BY Type
ON TABLE HOLD AS BMTOTALS
END
-RUN

JOIN CLEAR *
JOIN        FILE BMFILE   AT MFR TAG T1
  TO UNIQUE FILE BMTOTALS AT MFR TAG T2 AS J2
     WHERE T1.MFR = T2.MFR;
     WHERE T1.Type = T2.Type;
END

TABLE FILE BMFILE
  SUM MAX.T2.DSTPARTS NOPRINT
      MAX.T2.TOTSALES NOPRINT
   BY MFR
   BY Type
  SUM CNT.PartKey AS 'Count'
      SALES       AS 'Sum'
   BY MFR
   BY Type
ACROSS YearQtr AS ''
COMPUTE TotCount/I9 = C1; AS 'Count'
COMPUTE TotSales/D12M = C2; AS 'Sum'
END
-RUN


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, 2004Report This Post
Expert
posted Hide Post
Forgot to mention that the reason you would need to do two passes is that you cannot have a distinct operator in the first section of a multi-verb request.

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, 2004Report This Post
Expert
posted Hide Post



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, 2004Report This Post
Platinum Member
posted Hide Post
awesome!!
thanks so much. works perfectly.

I guess there is not drag and drop way for infoassist analysts.
 
Posts: 167 | Location: Montreal | Registered: September 23, 2014Report 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] Distinct count on a ROW Total

Copyright © 1996-2020 Information Builders