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,
®

Similar Messages

  • Query Designer: how to keep all char. in one vertical column when running?

    In query designer, if dragging char. one by one from the left to the row section, when running the query, these row characteristics all show in different columns.  How to show them in one column?  Just give you an example, usually the query result format would like the following:
    Salesman--Sales Office-Sales Org----Quantity
    John--Office1Org1--
    50
    Mark--Office2Org2--
    100
    Kevin--Office3Org3--
    30
    Now, we would like the query result looks like the following format:
    Salesman------Quantity
    John----
    50
    Mark----
    100
    Kevin----
    30
    Salesman Total------180
    Sales Office------Quantity
    Office1----
    xx
    Office2----
    xx
    Office3----
    xx
    Sales Office Total------xx
    Sales Org-------Quantity
    Org1----
    xx
    Org2----
    xx
    Org3----
    xx
    Sales Org Total------xx
    How to generate the above query?
    Thanks and we will give you reward points!

    Hi,
    What you want to do is 3 different views of the same report
    If you publish the information in Excel (workbook) you have to call 3 times the query in three different sheets, and manually do a summary....
    If you publish in the web, then you can have 3 times the same query but with different views on the same page. you can then control the three tables with the same navigation block...
    But your request is not the way Bex works...
    PYG

  • From two given tables, how do you fetch the values from two columns using values from one column(get values from col.A if col.A is not null and get values from col.B if col.A is null)?

    From two given tables, how do you fetch the values from two columns using values from one column(get values from col.A if col.A is not null and get values from col.B if col.A is null)?

    Hi,
    Use NVL or COALESCE:
    NVL (col_a, col_b)
    Returns col_a if col_a is not NULL; otherwise, it returns col_b.
    Col_a and col_b must have similar (if not identical) datatypes; for example, if col_a is a DATE, then col_b can be another DATE or it can be a TIMESTAMP, but it can't be a VARCHAR2.
    For more about NVL and COALESCE, see the SQL Language manual: http://docs.oracle.com/cd/E11882_01/server.112/e26088/functions119.htm#sthref1310
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and also post the results you want from that data.
    Explain, using specific examples, how you get those results from that data.
    Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
    See the forum FAQ: https://forums.oracle.com/message/9362002

  • How to get all the values in one column of a JTable

    How to get all the values in one column of a JTable as a Collection of String.
    I don;t want to write a for loop to say getValueAt(row, 1) eg for 2nd column.

    I don;t want to write a for loop to say getValueAt(row, 1) eg for 2nd column. You could always write a custom TableModel that stores the data in the format you want it. It would probably be about 50 lines of code. Or you could write a loop in 3 lines of code. I'll let you decide which approach you want to take.

  • How can I get the value of "Warehose" column in a form

    How can I get the value of "Warehouse" column in the form below (I mean what table that contain this value):
    Production Supervisor >> Batches >> (Button) Material Details >> (Button) Line Allocations
    Well, for more clearly! My problem is I must have the Unit Cost of Items, so I've got it in the cm_cmpt_dtl (table), but if I want to, I must create a relation that require 2 filed, they're Item_ID and Whse_Code.
    There's no problem with Item_ID, but Whse_Code seem to be the Mission Impossible (hix, I hate that film!!!!)
    I wonder if It was right to post this topic here. But anyway I just post my question here, hope I could get some help.

    wow, many, many, many.... and many thanks!
    Just add a tiny modify to check out the Batch_type
    doc_id = (select batch_id from gme_batch_header where batch_no='&batch_number' and batch_type = 0)
    Because the batch_no can be duplicated as we also create Batch and Filrm Planned Order.
    Many thanks for your support!
    P/S: Sorry for my terrible English :P

  • How to get the input value as a columns headings of the kye figer

    Dear all,
    the senario is i have keyfiger heading like DESPATCHES MADE ON (0CALDAY) and CUMMULATIVE DESPATCHES FOR (0CALMONTH), the 0CALDAY is the input value of the report. so how to get the value of the 0CALDAY and 0CALMONTH in the heading name of the key figer.
    I really appreciate for any help on this.
    wil assign pts for sure...
    thanks
    regards
    Mohan

    Dear  Venkat Ambati,Sumit Singn,Masi dandavate,
    thanks for reply.....
    ya got u r value able inputs but i don't no how to get the variable value to the column heading, if u guy's having any doc's means plz send me the same, my mail id is <u><i>[email protected]</i></u> or <i><u>[email protected]</u></i>
    thanks n regards
    Mohan

  • How to count a characteristic (Query Design)?

    What is the best way to count a characteristic in a query?  To be more specific, I would like to count the number of orders (characteristic 0COORDER).
    I have read the whitepapers:
    -HowTo Count the occurrences of a characteristic relative to one or more other characteristics
    -HowTo Calculate with Attributes
    I would like to build a query that looks like the following:
    Order Type      # Orders
    A                      3
    B                      5
    C                      4
    In my InfoCube,
    OrderID OrderLineID MaterialID Quantity Price ZCount
    1                             1
    1                             2
    2                             3
    3                             4
    3                             5
    3                             6
    I added a counter to my infoCube which counts the number of line items per order (from HowTo count occurences of characteristic whitepaper).  <b>However, now I need to count the number of orders.</b>
    One approach I tried was to create a dummy calculated keyfigure, which i set to a constant of 1.  I then created another calculated keyfigure and used Count ( dummyKeyFigure).  I could have also achieved the same result by using SUMGT (dummyKeyFIgure).  However, this only works if you have orderID in your query row:
    OrderID      dummyKeyFigure (hidden)         
    1                        1
    2                        1
    3                        1
    Result:                3  (SUMGT of dummyKeyFigure)
    I also read a thread that discussed another alternative on how to use a replacement path variable to count a characteristic (using the key)... however the procedure wasn't clear.  When I tried to create a variable on orderID using a replacement path, it asked for either a variable or query to use... and I got "stuck" from there.  Can you use a replacement variable to count the number or orders? 
    What are the different alternatives (and procedures) for counting the number of orders?
    Thanks,
    -B
    Message was edited by:
            Brendon Lipchen
    Message was edited by:
            Brendon Lipchen

    Hey Olivier.
    I do have Key Figures in my cube.  However, I only want to count the number of Orders in my InfoCube.
    For your solution, you say to create a CKF.  In order to create a CKF, you need a KF to put in your CKF calculation (note you omitted this step from your solution).  There is no KF in the infocube to use for the Order count (we are creating "this" CKF to get the Order Count).  If there is no KF you can use in your InfoCube to get the Order Counter, then you need to create a replacement path variable to use in your CKF calculation.  After you have created a replacement path variable for OrderID, you can place this variable in your CKF calculation (instead of using a KF).  Make sense?

  • BEx query needs to count unique characteristic values

    Is there any way to build a query using BEx query designer to count the number of unique values of a characteristic.  For instance, my cube has detailed transactions for claim information.  Each claim number can have multiple products.  My query need to show the number of claims that exist for each product.  I don't want the detail of the claim number, just how many claims exist.
    Product          Gross Paid Loss        Claim Count
    Total Auto                $ 43,865.01              ?
    Total Property  $ 4,068,321.57              ?
    Not assigned                19,426

    Hi,
    Creat calculated  keyfigure with data functions Count value and save with technical name.
    Right click on that go to propertes, select count with exception aggregation - Claim Number,
    also use after aggregation and decimal places '0'.
    Regards
    Malyadri

  • 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

  • When we run query how it gets the characteristic values and attributes.

    Hi,
    When we load transaction data it chacks characteristic values then SIDs then DIM IDs then insert  DIM IDs into fact table but when we run the query how it checks and gets the characteristic values and attributes.
    Bye
    GK

    when we run the query how it checks and gets the characteristic values and attributes.
    Just the opposite way you have described. It gets from the corresponding masterdata tables, with the connected SID.

  • How to use a characteristic value variable in a formula?

    Hi all,
    I have created a characteristic value variable (manual input) for 0CALDAY in a query to get the Start & End date. There is requirement in the report to display a KF showing the duration between Start & End Date.
    I have tried to create a Formula Variable with Replacement Path, Ref Char 0CALDAY. In the Replacement Rule, there is an option to Replace Variable With variable. However, I wasn't able to locate the variable I have created for user input.
    Any idea how to achieve this?
    Many thanks,
    Yoong-En

    hi,
    if you have the start and end dates as user entry then follow this
    1) create a formula variable with reference char as start date of the type customer exit
    2) create another formula with end date as reference char of type customer exit
    3) in the cmod write the code your logic should be in such a way the the value at the user entry should be passed on to this formula variable the same for end date code
    4) create a formula with ( start date formula variable - end date formula variable)
    you can use this code
    WHEN 'ZV_YRFKDAT'.(formula  variable name)
        IF I_STEP = 2. "after the popup
          LOOP AT I_T_VAR_RANGE INTO LOC_VAR_RANGE
          WHERE VNAM = 'ZV_KEYDAT1'.(user entry variable name)
            CLEAR L_S_RANGE.
            L_S_RANGE-LOW = LOC_VAR_RANGE-LOW. "low value, e.g.YYYY (2006) part of key date (20060625)
            L_S_RANGE-SIGN = 'I'.
            L_S_RANGE-OPT = 'EQ'.
            APPEND L_S_RANGE TO E_T_RANGE.
            EXIT.
          ENDLOOP.
    repeat teh same for end date
    hope this helps
    Thanks
    krishna.y
        ENDIF.

  • BEx Designer: How to count if an InfoObject(field=ProblemNr)  is empty

    Hi,
    in the ROWS i have an InfoObject (let's say ProblemNumber) and in the COLUMNS another InfoObject (Date).
    The IO in the Rows is not a primary key and it's not always filled in. The OrderNr might be a primary key.
    I want to find out how many of the entries in a specific month (IO Date) have ProblemNr and how many not.
    So basically would lool like the following:
                                  April
    With ProblemNr:    25
    W/o Problem Nr:   18
    Would you give me tips how i can show such a result.
    Thank you!

    I have two Field in the Multiprovider: DocNumber & DeliveryDate.
    In the Query Design I created a Count (Calculated Key Figure) to count the entries
    since Iu2019m not allowed to change anything in the Data Model.
    The DocNumber might and might not have a DeliveryDate, Ex:
    DocNumber     DeliveryDate 
    1234               12.03.11
    2345                    --
    4567                11.01.10
    6789                01.05.11
    So i need to design a Query to count Number of Documents (DocNumber ) that have
    No(Empty) DeliveryDate  & also Number of Documents (DocNumber ) that
    have DeliveryDate.
    So the result would look like something like this:
                                  April    May    June   July
    No DeliveryDate     54       23          22         56
    With DeliveryDate   32       3             52         26
    So there are 54 Documents that have DeliveryDate Field empty and
    32 Documents with DeliveryDate filled in.

  • How to Count a Characteristic Occurence?

    Morning,
    I have Assembly(Material) being displayed as a Row item in my query. My need is to count the number of rows for Assembly in the query. I referred to "How to Count" doc, but that counts every occurence of assembly. Whereas, I need to count an Assembly just once.
    Can somebody help me on this?
    Thanks.

    Vijay,
    Here is how it is desired:
    Plant   Assembly  Count
    7835   711712101    1        
    <   >   711712103    1
    <   >   711712111    1
    <   >   711712401    1
    <   >   711713101    1
    Can you explain how I can do with this?

  • Checkbox as a query item - how do I get its value into my SQL

    I have a search region where the user enters some parameters to filter the records returned from the query. I have a checkbox that represents Active or Inactive. I created it using the APEX_ITEM.CHECKBOX function. So if checked I want the sql to order by Active records else if unchecked to order by inactive records after they press the submit button. So how do I get the checked or unchecked value from this checkbox into my SQL query.
    Message was edited by:
    ca114422

    You can have a look here:
    http://htmldb.oracle.com/pls/otn/f?p=31517:99
    There is an example on how to include various item values
    into your query.
    By the way, what is your name?
    Denes Kubicek

  • How to sort the characteristic values in layout

    Hello,
    I wont to use a layout with key figs in data columns and two characteristics in lead columns. The problem is that the sorting of first characteristic values is displayed in alphabetical order. How can I change the order to another exact defined combinations for characteristic values?
    I read the thread with the same problem (see below the link), but the solutions are not satisfacroty.
    Has anyone another idee?
    Thanks for any help!
    Larissa Bräutigam

    Hi Larissa;
    I had the same problem and they propose this:
    Attributesu0092 order that the system displays in the Planning Layout
    That was not the solution presented to the customer. Because of system performance, a programmer was there and created a VBA code. But I wasn't there so I don't have the code.
    regards

Maybe you are looking for

  • Combine iTunes from several computers(all macs) to make one full library???

    I have iTunes on our desktop and two laptops, and my iPod is synced to my personal laptop. All of the computers have the some of the same music, but each has additional music we have added over time. How do I load the music from both laptops to the d

  • Line Item: After reading all your links and discussions

    From the links and the discussions I was referred to in a previous post, please correct me if I am wrong. I understood that with if a characteristic is going to have several values (defined in that case as "has cardinality"), then it is better to mak

  • I7 iMac with Bootcamp 3.1 and Windows7 64-bit won't resume from sleep

    When I try to resume from sleep, by clicking the magic mouse button, the screen comes up and I can move the mouse around but the bluetooth keyboard does not work and I can't launch any programs. Have to use the rear button to force a power off and re

  • Can't drag songs from Library into Playlist

    I have followed the instructions but have not been able to drag songs into any playlists at all. Any help or suggestions will be appreciated.

  • Tomcat deployment - help!

    Hi everybody, My application works perfectly on the bundled server but when I deploy it to Tomcat I get an error. I added the JSTL libraries as explained in the deployment example but I think the error comes from the code as there is a nullpointerexc