How to count distinct excluding a value in business layer?

Hi all,
I'm having a column which has many values. I need to make this is as a measure with count distinct aggregator. But i should not count 0 in the column. How can i do this. If i try to use any condition means the aggregator option is disables. Please help
Thanks

Look this example:
I made in BMM in the SALES fact table measure:
Count_Distinct_Prod_Id_Exclude_Prod_Id_144
I'll count distinct PRODUCTS.PROD_ID, but exclude PROD_ID=144 in counting.
Make this measure like this:
1. New object/Logical column
2. Go to data type tab and click EDIT on the logical table table source
3. Now, in the general tab add join to a table (in my case PRODUCTS)
4. Go to the column mapping tab -> show unmapped columns
5. In the new column (in my case Count_Distinct_Prod_Id_Exclude_Prod_Id_144) write code like similar:
CASE WHEN "orcl".""."SH"."PRODUCTS"."PROD_ID" = 144 THEN NULL ELSE "orcl".""."SH"."PRODUCTS"."PROD_ID" END
6. Click OK and close the logical table source window
7. Now, in the logical column window go to aggregation tab and choose COUNT DISTINCT.
8. Move the measure Count_Distinct_Prod_Id_Exclude_Prod_Id_144 in the presentation area
9. Test in Answers (report cointains columns as follow)
PROD_CATEGORY_ID
Count_Distinct_Prod_Id_Exclude_Prod_Id_144
And the result in the NQQuery.log is:
select T21473.PROD_CATEGORY_ID as c1,
count(distinct case when T21473.PROD_ID = 144 then NULL else T21473.PROD_ID end ) as c2
from
PRODUCTS T21473
group by T21473.PROD_CATEGORY_ID
order by c1
Regards
Goran
http://108obiee.blogspot.com

Similar Messages

  • Query Designer - how to count distinct  characteristic values in a column

    Hello Experts,
    I need to count the number of distinct occurences in a column and use it later for a percentage calculation. I'll give you a concrete example:
    Promotion_ID   Product    Promoted
    A  ******************  P1 ********  1
    A  ******************  P2 ********  0
    A  ******************  P3 ********  1
    B  ******************  P1 ********  0
    B  ******************  P3 ********  1
    C
    D
    A promotion ID can have more than 1 product associated with it. A product can be promoted (1) or not. A promotion_ID can be also empty (no products C and D)
    I need to calculate for each product the percentage of promotions where the product is promoted out of ALL promotions (4) or
    P1  25 %
    P2  0 %
    P3  50%
    How can I model this in the Query Designer ? How can I count the distinct Promotion_IDs ?
    Any ideas will be appreciated.
    Thanks
    Rado

    Hi,
    Please take a look at the docs below.
    https://websmp102.sap-ag.de/~sapdownload/011000358700002762432003E/HowToCount.pdf
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/7e58e690-0201-0010-fd85-a2f29a41c7af
    Regards,
    ®

  • How to count the elements with values in a Source?

    I have 2 measures which needs the same dimensions as inputs. So i use "Source.join()" to fill the inputs of both the measures like this:
    Source result = m1.join(m2).join(d1).join(d2);
    m1, m2: the "Source"s of the "MdmMeasure"s
    d1, d2: the "Source"s of the "MdmPrimaryDimension"s
    So before retrieving the results, i want to know how many lines i'm gonna have:
    Source resultCount = result.count();
    Here is my problem : the 2 measures have "NA"(1) but not the same "line" of data, and count returns the number of lines with data for the first measure (m1).
    I would like to have the number of lines which have data in at least 1 measure.
    example:
    | d1 | d2 | m1 | m2 |
    | a | b | 1 | 2 |
    | b | c | NA | 2 |
    | b | c | 4 | NA |
    | b | c | NA | NA |
    right now, i get 2, but i would like to get 3
    Can you help me please?
    NA(1) : when ValueCursor.hasCurrentValue() return false.
    Source(2) : http://oraclesvca2.oracle.com/docs/cd/B14117_01/olap.101/b10994/oracle/olapi/data/source/Source.html

    You have to put table name in Capital letters
    Like
    SELECT COUNT(1)
      FROM user_tab_columns
    WHERE table_name = 'EMP';
    or
    SELECT COUNT(1)
      FROM user_tab_columns
    WHERE table_name = UPPER('Emp');Regards
    Arun

  • How to include and exclude external infoobject values in a hierarchy

    Hello experts,
    I'm working with hierarchies and the problem I have is that I don´t know how to include nor exclude a value in the definition of the hierarchy.
    For example, I want to show in a query some cost elements related to some functional areas, so I've created a hierarchy for md funcional area. But I don't want to show every cost element related to one functional area but only some of them. I've defined 0costelmnt as a external characteristic for 0func_area infoobject so that I can specify in the hierarchy the cost elements I want to show. But it doesn´t work, in the report all cost elements are showed. How can I specify the ones I want to show?
    thank you very much.

    Any ideas please?

  • Count the number of values in a two dimensional array

    i am trying to figure out how to count the number of values in a two dimensional array.
    numScores = student[i][j].length;This doesn't work, i am trying to find a way of counting the columns

    Object[][] o;
    int tot = 0;
    for(int x = 0 ; x < o.length ; x++)
       tot += o[x].length;
    }If it's not a jagged array, however, this would be easier:
    int tot = o.length * o[0].length;

  • How to display the count distinct in a report

    hi,
    i have a report with multiple columns in it and with column, say A; i need to display in a calculated column B how many distinct values there are in A across the entire report; how to do that?

    Hi.
    For example:
    CALENDAR_YEAR
    CALENDAR_MONTH_DESC
    count(distinct TIMES.CALENDAR_MONTH_DESC by TIMES.CALENDAR_YEAR)
    Count will give you how many distinct months are in year.
    Regards
    Goran
    http://108obiee.blogspot.com

  • MeasureExpression property - Is there a possibility to implement distinct count with exclude empty?

    I have a measure which needs to have distinct count aggregation with exclude empty.
    Is there a possibility to specify MeasureExpression property to achieve the same? I have set the aggregation of the measure to none and I have typed the following function,
    Count(Distinct(Column_name),EXCLUDEEMPTY)
    where as the measure reads 0(zero) upon processing. Is there any other way to achieve this?
    The data feed has nulls included too for the column which this is to be achieved, which cannot be modified in the data level.
    Regards,
    Kantha Girish

    Hi Kantha,
    According to your description, you want to implement the distinct count aggregation, right? In this case, we can use a query like
    count(nonempty([DimName].[HierarchyName].[LevelName].members,[Measures].[MyMeasure]))
    Here are some blogs about how to implemet distinct count aggregation, please refer to the link below.
    http://blog.sqltechie.com/2009/09/distinctcount-analysis-service.html
    http://richardlees.blogspot.com/2008/10/alternative-to-physical-distinct-count.html
    If I have anything misunderstood, please point it out.
    Regards,
    Charlie Liao
    TechNet Community Support

  • Count distinct values in report builder

    i have a situation where i have to count distinct number of customers.
    i have a query which returns the list of values of bill_to_customer_id from ra_customer_trx_all table and i have to display only the number of distinct customers. i cant do this in the query because it has to be grouped and i am doing it in an aging report. i have to list the number of distinct customers in each aging period. can anybody please help me how to achieve this in reports 6i.
    thanks

    how can i count distinct values in reports?
    the situation is like this
    i have a query which lists customer_id, invoice number, amount due
    so what i want is to count the distinct customer_id and display the number of distinct customers. one customer_id can be repeated any number of times but i should count it only once.

  • How to get Distinct Values from Answers

    Hi,
    How to get Distinct values from answers, i've tried to put some functions on it.
    Thanks,
    Malli

    Malli,
    Are you trying to fetch data from Dimension Attr OR Fact Measures? Did you try the advance tab - > Advanced SQL Clauses - > Check this box to issue an explicit Select Distinct.

  • How to select distinct values from a table when it has composite primary ke

    Hi
    I have the requirement like , I need to select distinct one column values from the table which has composite primary key. How to acheive this functioinality using view object.
    Eg : Table 1 has col1 and col2, col3
    col1 col2 col3
    1 A NA
    1 B NA
    2 A NA
    3 C NA
    2 D NA
    primary key (col1,col2)
    I have to select distinct col1.
    Thanks

    Hi
    I got the solution for above. By Creating the read only view object we can acheive this.
    thanks

  • How to  restrict the output of 0VENDOR by excluding the # value in rows?

    We generated a query whose InfoProvider is 0Vendor. Run the query, find the last row shows # as Vendor number and the description of it is "Not Assigned".  Then we go to this query design screen, pick 0Vendor in the rows frame, right click and select Restrict, there are two tabs, one is "Fixed Values", the other one is "Variables".  Click "Fixed Values" tab, can see that 1st value is "#", but from this window, we can't see any place to exclude this "#" value. 
    We are very appreciated anyone's input on how to get rid of the "#" value when run query.
    Thanks

    Hi,
    Eliminating # in the result area..
    Necessary steps to avail this functionality:
    Written a VB macro for the same
    Here are the steps to do the same
    1) In excel menu Tools->macro
    2) Enter the macro name say SAPBEXonRefresh
    3) click 'create', will go to visual basic editor
    4) To display '#' as '' “ ( blank) paste the following code
    Sub SAPBEXonRefresh (queryID As String, resultArea As Range)
    Dim c As Range
    For Each c In resultArea.Cells
    If c.Value = "#" Then c.Value = ""
    Next c
    End Sub
    5) Close the editor and click on refresh again.
    After refresh you will get blank in the columns with #.
    Hope this will help you.
    Thank you,
    Regards,
    G.Ram

  • Distinct Count of Non-null Values

    I have a table that has one column for providerID and then a providerID in each of several columns if the provider is under a particular type of contract. 
    I need a distict count of each provider under each type of contract for every county in the US.
    distinct count is almost always one more than the actual distict count because most counties have at least one provider that does not have a particular contract and the distict count counts the null value as a distict value.
    I know I can alter the fields to have a zero for nulls, ask for a minimum count and then subtract 1 from the distict count if the minimum is zero, but I hope there is an easier way to figure distict counts of non-null values.
    any suggestions?
    Thanks,
    Jennifer

    Hello,
    *I need a distict count of each provider under each type of contract for every county in the US*
    To the above requiremetn,
    I will suggest the following approach.
    Use group expert formula  for country, contract and provider.
    Now you will have the hierarchy to which level you want to apply distinct count. You can do it as suggested by ken hamady.
    Regards
    Usama

  • How to count Unique Values in BEx

    Hi Guys,
    Can anybody please let me know how to count unique values of a characteristic.
    Thanx in advance
    Peter

    I have a similar scenario. If i drill up on the characterstic that had a count of one in each record, the total number of records should be stay equal to the summarised results in the last screen.
    Would someone know how to do that .
    Arti

  • How to Count Row Values

    Hi,
    In a Table 50 Columns are there and 10 Records are there. In those 10 records are not inserted all columns (Some are null values). How to find The Count of Record (Row) Values .
    For Example
    Table
    p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 .........
    10 20 30 40 50
    20 30
    60 80
    In the Above table, how to find
    the count of values in 1st record is 5
    the count of values in 2nd record is 2
    the count of values in 3rd record is 2
    Thanks & Regards,
    Hari

    Hi ,
    CREATE TABLE Sample
    Col1 NUMBER(2),
    Col2 NUMBER(2),
    Col3 NUMBER(2),
    Col4 NUMBER(2),
    Col5 NUMBER(2),
    Col6 NUMBER(2),
    Col7 NUMBER(2),
    Col8 NUMBER(2),
    Col9 NUMBER(2),
    Col10 NUMBER(2)
    Table Created.
    I inserted Data like below
    Col1     Col2     Col3     Col4     Col5     Col6     Col7     Col8     Col9     Col10
    10          20          30     40     50     70          60
         10     30     40     50     60               20     
    10               20               30               
         10           20               30          40
    10          20               30          40     50     
    10     20     30 40     50     60     70     80      90      100
         10 20                                   
    10               20          30               40     
         10     20 30 40      50     60     70          
    10 20 30 40
    In the above data, How To find out
    1st row has 7 Values (Which Columns are not null)
    2nd Row has 6 Values
    3rd Row has 3 Values
    4th Row has 4 Values
    5th Row has 5 Values
    6th Row has 10 Values
    7th Row has 2 Values
    8th Row has 4 Values
    9th Row has 7 Values
    10th Row has 4 Values

  • How to add default value to the Exclude single value in selection screen..

    Hi Experts,
    i have searched in sdn, but not able to get proper results,
    in my report i have a selection screen, in that there is a Select-option like status, for this status i need to exclude '02'
    for this i need to add the default value under exclude singale values option, not in lower and upper limit.
    can anyone help me...
    Regards,
    Sudha.
    Moderator message: please search for available information/documentation before asking, don't just claim you did.
    Edited by: Thomas Zloch on Oct 27, 2010 2:50 PM

    Hi,
    you can use the function module SELECT_OPTIONS_RESTRICT .
    This function module simplifies the handling of SELECT-OPTIONS on the selection screen by restricting possible selection options and signs.
    By calling this function module, you can restrict the number of selectio options available for the chosen selection field. You can also disable the function allowing users to enter values to be excluded from the selection (SIGN = 'E').
    Regards,
    S.Velsankar

Maybe you are looking for

  • Some songs don't play in iTunes

    13 of my songs that i know of wont play in itunes, when i press play, double-click etc. there's no reacton, it doesnt even show the song in the display, and i tried to delete some of them to see if theyd be added to my library again..and they wont...

  • Read only custom field for particular user

    Hi, I have requirement to few enterprise custom field should be edited by only top management,Project manager and team member can only read the same field. Like i have one custom enterprise  baseline finish date,which need to update by only IT GM,and

  • Oracle Listener Register Issue

    Hi , I have got a problem with registering a test db CBA04 with listener LISTENER_TEST. Initially this DB was configured to the listener -LISTENER. Now, I want to separate this instance to LISTENER_TEST and hence configured this to port 1522 using ne

  • Producer leak in MessageProducer.send( Destination, Message ) ?

    We have a client/server message passing system (using 3.6 SP3). The clients create temporary queues and the server replies in these queues. The server uses an unidentified MessageProducer (i.e., from session.createProducer( null ) ) to reply. Clients

  • Hi, I need to connect by internet key to the network...How it goes?

    I wuold like to connect my MacBook on internet by an internet key, but it doesn't work... How I can solve this problem?? Thank you