IB - Developer Center    Forums  Hop To Forum Categories  FOCUS/WebFOCUS    Distinct Count in a subhead
Go
New
Search
Notify
Tools
Reply
  
-star Rating Rate It!  Login/Join 
RB
Gold member
Posted
Hi,
I would like to display the distinct count of a field in subheading. Does any one has ideas on how to do this?

Thanks.
 
Posts: 76 | Registered: October 28, 2003Reply With QuoteEdit or Delete MessageReport This Post
Master
Posted Hide Post
CNT.DST.itemkey, as a verb object, gives the count. Not sure you can imbed such a construct in a header/footer, as " <CNT.DST.itemkey " If not, substitute a COMPUTEDd field, like so:

TABLE ...
SUM CNT.DST.itemkey NOPRINT
COMPUTE distinct/I5C= CNT.DST.itemkey; NOPRINT
BY XXX
BY YYY
BY ZZZ
ON XXX SUBHEAD
"... <distinct ..."
END
 
Posts: 529 | Location: NYC | Registered: January 11, 2005Reply With QuoteEdit or Delete MessageReport This Post
Virtuoso
Posted Hide Post
The DST operator is picky in the sense that is only on SUM or WRITE verbs and it must be at the lowest level on the aggregation chain.
So this works

SET STYLEMODE= FIXED
TABLE FILE CAR
SUM CNT.DST.MODEL
BY COUNTRY
END

but this doesn't
SET STYLEMODE= FIXED
TABLE FILE CAR
SUM CNT.DST.MODEL
PRINT COUNTRY MODEL
BY COUNTRY
END

0 ERROR AT OR NEAR LINE 28 IN PROCEDURE _ADHOCRQFOCEXEC *
(FOC1867) DST OPERATOR MUST BE AT THE LOWEST LEVEL OF AGGREGATION


So for unique counts you may want to create a unique counter field and ensure the file is in the order wanted when creating.

This works
SET STYLEMODE= FIXED
TABLE FILE CAR
PRINT COUNTRY MODEL
COMPUTE CNTR/I4 = IF MODEL EQ LAST MODEL THEN 0 ELSE IF COUNTRY NE LAST COUNTRY
THEN 1 ELSE 1;
BY COUNTRY NOPRINT
BY MODEL NOPRINT
ON TABLE HOLD AS HOLD1
END
TABLE FILE HOLD1
SUM CNTR NOPRINT
BY COUNTRY
PRINT MODEL
BY COUNTRY
ON COUNTRY SUBHEAD
" "
"UNIQUE MODELS ARE <CNTR"
" "
END

Of course the car file doesn't have a lot of models and you may not want to use a hold file.
A define would work if the input file is in the order wanted.
 
Posts: 1307 | Location: Council Bluffs, IA | Registered: May 24, 2004Reply With QuoteEdit or Delete MessageReport This Post
<WFUser>
Posted
The simplest way that I can see to put the number of unique instances in a subhead of a sort is to get that count and then join to it as follows:

TABLE FILE CAR
SUM CNT.DST.MODEL AS DSTMODS
BY COUNTRY
ON TABLE HOLD AS DSTMODS FORMAT FOCUS INDEX COUNTRY
END
JOIN COUNTRY IN CAR TO COUNTRY IN DSTMODS AS J1
TABLE FILE CAR
PRINT BODY MODEL CAR
BY COUNTRY
ON COUNTRY SUBHEAD
"<COUNTRY HAS <DSTMODS MODELS"
END
 
Reply With QuoteEdit or Delete MessageReport This Post
RB
Gold member
Posted Hide Post
Both solutions are great. Thank you very much guys!
 
Posts: 76 | Registered: October 28, 2003Reply With QuoteEdit or Delete MessageReport This Post
 Previous Topic | Next Topic powered by eve community  
 

IB - Developer Center    Forums  Hop To Forum Categories  FOCUS/WebFOCUS    Distinct Count in a subhead

Copyright © 1996-2008 Information Builders, leaders in enterprise business intelligence.