How to exclude certain values in a measure.

Hi,
I have fact data something like..
ID
MyValue
MySetValue
1
200
1
2
300
1
3
400
0
4
500
0
5
600
1
Now I want to create a measure MyValue which would be sum(MyValue). This i can do using SUM aggregation.
But I also want a measure which is SUM(MyValue) but excludes rows for which MySetValue is 0.
So first measure should return 2000 and second measure should return 1100.
I know this can be done by adding a new column in view or in DSV which does the filtering. But is there a way of doing the same in calculated member ?
Thanks.
liquidloop[at]live[dot]co[dot]uk

The best way is going to be creating a calculated column in your DSV (or view) and then defining a stored measure based on that calculated column. When business rules are applicable at the grain of the fact table, the best approach is going to be to include
that logic at the fact table. There's ways to create it in the Calculation Tab of the Cube Editor but it's almost never the right way to go. The method that Charles uses above is a devastating bad approach as an aggregation function over a Filter clause though
possible, the SSAS Engine when it sees a statement like those should just raise an error rather than processing the statement. (See point #1 in the following blog:
http://sqlblog.com/blogs/mosha/archive/2008/10/22/optimizing-mdx-aggregation-functions.aspx )The real issue with the approach that Charles uses in your case above is that a Filter statement applies to the current context in aggregate and WILL NOT apply
to each row at the source. Therefore, not only inefficient, it's also incorrect.
To really approach the problem, you would need to create a dimension based on the MySetValue column. In the small example that you have above, that dimension would only have a single attribute hierarchy with  two members but in a real life situation,
that column could and often would be a non-discrete function. Saying that you only have two possible values, and only the single attribute hierarchy with those two members, you could define the new measure as the following:
CREATE
MEMBER CurrentCube.[Measures].[Modified MyValue]
AS
IIf(
              [MySetValue].[MySetValue].CurrentMember
IS [MySetValue].[MySetValue].&[0],
NULL,
              [Measures].[MyValue]
FORMAT_STRING="#,##0";
However, the slice, ([MySetValue].[MySetValue].[All],[Measures].[Modified MyValue] would still be exactly equal to [Measures].[MyValue]. You could fix that using a SOCPE statement.
SCOPE(
       [Measures].[Modified MyValue],
       [MySetValue].[MySetValue].[All]
THIS = (
              [MySetValue].[MySet Value].&[1],
              [Measures].[MyValue]
END
SCOPE;
So as you can see, just do it the right way to begin with. Create a column in your DSV and create a measure from that calculated column. 
Martin
Martin Mason Wordpress Blog

Similar Messages

  • How to exclude certain playlists from being shuffled?

    I have Video IPOD and would like to know how to exclude certain play lists from being played when the "shuffle song" function is on?
    Appreciate your help.

    Going back to the beginning I think I misinterpretted your original question. I thought you wanted to be able to turn on the Shuffle Songs function of the iPod and when you played any playlist it would shuffle normally but you wanted to have some playlists that would play without shuffling without having to turn off that function.
    Now I think what you wanted to say was you want to shuffle song when playing your library on the iPod but if certain songs exist in your "do not shuffle" playlist, they would be skipped, right?
    If that is the case, you can do it with some Smart playlist manipulation. First create the "Do Not Shuffle" playlist and put everything in there that you do not want to show up when you are shuffle playing your library. Now create a new Smart Playlist where the rules are "Playlist IS NOT [do not shuffle]". Make that the only rule, check live updating and only checked songs. What will happen is that playlist will contain your entire library EXCEPT the ones you don't want shuffle played.
    Now when you listen to your iPod, you can use the Shuffle Songs option turned ON and play that smart playlist which will basically let you hear anything and everything in your library shuffled EXCEPT for those songs you designated to not include.
    Patrick

  • How to display certain values from ValueHelp

    Hi,
    how do i display only certain values in ValueHelp of the Variable Input section? currently i see all values that were maintained in Master Data. I have tried different options available in the Business Explorer Tab of the InfoObject in question.
    Any suggestions?
    SD

    Hi,
    Refer the follwoing document.
    http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/20ecb78c-374a-2d10-c6af-f024f19b785d
    I hope it will help.
    Thanks,
    S

  • How to exclude certain rows in the ALV display from the total?

    Hi,
    May I know is there a way to exclude certain rows that are shown in the ALV control from the calculation of grand total?
    Thanks much.

    See, if
    function module REUSE_ALV_TRANSFER_DATA 's
    IT_EXCLUDING   .... param
    works for you.

  • How to restrict a filter to exclude certain values from the report

    Hi,
    I have a scenario,
    I have to filter on date "date of destroy/return" to exclude the batches which are destroyed/returned in the report.
    Thanks,
    Jyothi.

    in the screen where u drag selected dates from left to right...there..
    right click on each of the selected dates..click on 'exclude from selection'..
    u will see icon color changes to RED..
    values will get excluded from selection..
    Vishvesh

  • Multi Resource Scheduling MRS - How to exclude certain Maint Activity Types

    is there a way to exclude orders that have a specific maintenance activity type.  We have standing work orders that in reality we should not have appear on the planning board.  Well, we really shouldn't have any standing orders but we do.
    Has anyone had this issue and been able to solve it.   thanks, Linda

    While a lot of MRS configuration includes maintenance activity type as a way to refine the circumstances in which something occurs (e.g., stretched assignments), that is not the case for defining which demands will be brought into MRS.  However, while not positive, I believe "BAdI:  Integration of Maintenance/Service Order with MRS (ERP)" can be used for this purpose.
    Mark

  • How to exclude certain operations in PM order from task list?

    Hi Experts,
    we have number of operations in task list and being attached to in maintenace plan. While scheduling Miantenance Plan system is creating order as per requirement with set of all operations present in the task list. we would like to restrict certain operations needs to be appeared in the maintenance order? any enhancement will work for this kind of user requirements?
    suppose if task list is having 100 opeartions. when we do scheduling by using this task list through maintenance plan system is defaulting 100 opreations in the order as per standard. we would like to restict certain operations not to appear in the order, even it is present in the task list!
    Thanks in advance
    Regards,
    Krishna

    Hi ,
    If you could convert this order type as Service order you will get a field called Service Product. Then you can use Classification and Characteritics for the service product and the Tasklist to choose the required operation in the service order created by the system. You need to use the techniques of varinat config to achieve this functionality.
    AlexPr

  • How to exclude partner in FPVA screen ?

    Hello,
    Our project use collection strategy.
    We need to exclude some Business Partner from dunning proposal (FPVA) but without add a lock.
    We have a range value in BP Number : 1000000 to 18999999
    And I add an exclusion for 10 partners in "Custom Selections" but it doesn't work... Partners are dunning...
    Do you have a solution ?
    Otherwise, I will add a condition in event 311...
    Thanks,
    Mathieu

    Hi Mathieu,
    The only purpose of the custom selections tab is exclude certain values so that the Dunning Proposal can be executed as per business requirement.
    If that is not working, please raise an OSS with SAP for the same.
    You can always plug in an FM in event 311, but I would recommend to get the custom selctions tab rectified.
    Hope it helps...
    Thanks,
    Amlan

  • How to retrieve the values from a table if they differ in Unit of Measure

    How to retrieve the values from a table if they differ in Unit of Measure?

    If no data is read
    - Insure that you use internal code in SELECT statement, check via SE16 desactivating conversion exit on table T006A. ([ref|http://help.sap.com/saphelp_nw70/helpdata/en/2a/fa0122493111d182b70000e829fbfe/frameset.htm])
    If no quanity in result internal table
    - There is no adqntp field in the internal table, so no quantity is copied in itab ([ref|http://help.sap.com /abapdocu_70/en/ABAPINTO_CLAUSE.htm#&ABAP_ALTERNATIVE_1@1@]).
    - - Remove the CORRESPONDING, so quantity will fill the first field adqntp1.  ([ref|http://help.sap.com/abapdocu_70/en/ABENOPEN_SQL_WA.htm])
    - - Then loop at the internal table and move the quantity when necessary to the 2 other fields.
    * Fill the internal table
    SELECT msehi adqntp
      INTO TABLE internal table
      FROM lipso2
      WHERE vbeln = wrk_doc1
        AND msehi IN ('KL','K15','MT').
    * If required move the read quantity in the appropriate column.
    LOOP AT internal_table ASSIGNING <fs>.
      CASE <fs>-msehi.
        WHEN 'K15'.
          <fs>-adqnt2 = <fs>-adqnt1.
          CLEAR <fs>-adqnt1.
        WHEN 'MT'.
          <fs>-adqnt3 = <fs>-adqnt1.
          CLEAR <fs>-adqnt1.
      ENDCASE.
    ENDLOOP.
    - You could also create another table with only fields msehi and adqntp and then collect ([ref|http://help.sap.com/abapdocu_70/en/ABAPCOLLECT.htm]) the data to another table.
    Regards,
    Raymond

  • How to look for a certain value in a database using sql

    Hello everyone. How do you do this in SQL? Or, is there a way to look for a certain value in a database? What I'm trying to do is this:
    I want to look for the exact value "abcdefg" in the database so that oracle will return me details on the following that contains the said value:
    1. the name of the table(s)
    2. the column/field name(s)
    Note: "abcdefg" could exist in different tables with different column names with different data types.
    Any help is much appreciated. Thanks.
    UPDATE: What about if I just want to check those fields/columns with string data types?
    Message was edited by:
    dongzky
    Message was edited by:
    dongzky

    Just a teeny tweek
    DECLARE
       l_dummy   VARCHAR2 (4000);
    BEGIN
       FOR rec IN (SELECT table_name
                     FROM all_tables)
       LOOP
          FOR rec2 IN (SELECT column_name
                         FROM user_tab_cols
                        WHERE table_name = rec.table_name)
          LOOP
             BEGIN
                EXECUTE IMMEDIATE    'select 1 from '
                                  || rec.table_name
                            || ' where to_char('
    || rec2.column_name
    || ') = ''CAS'' and rownum = 1'
                             INTO l_dummy;
                DBMS_OUTPUT.PUT_LINE (rec.table_name || ' ' || rec2.column_name);
             EXCEPTION
                WHEN NO_DATA_FOUND
                THEN
                   NULL;
             END;
          END LOOP;
       END LOOP;
    END;

  • How to exclude values in the query designer

    Hi everybody,
    i need your help!
    I need to exclude certain information from a report, but as could enter new values in the future, I see it now.
    Ex.
    CreatedBy contains the following values:
    MSanz
    PRojas
    Soporte
    Soporte1
    Soporte2
    I need to exclude anything value that is Soporte* for first report
    and the second report include anything value Soporte*
    first report
    MSanz
    PRojas
    Second Report
    Soporte
    Soporte1
    Soporte2
    thanks for your help
    Manuel
    Edited by: Manuel Sandoval on May 30, 2008 6:35 PM

    Hi Manuel,
    There are two ways to exclude the fields of Createby.
    1. Excude Soporte,Soporte1,Soporte2 in the first report.  Select createby -->, right click >Restrict> select  Soporte,Soporte1,Soporte2  and pull from left to right > right click(3 fields)> exclude.
    Similary for second report exclude MSanz, PRojas.
    Or
    After restricting include only the necessary fvalues  from right to left for creteby field.
    Best method is include one, for performance point of you.
    Second approach is create two user exit variables. one to include Soporte,Soporte1,Soporte2 (3 values) in the variable and second variable to include MSanz, PRojas. You can maintain these two variables values in the tvarvc table and use these variable  in the reports directly. This approach is very very useful if you want to use this variable in many reports ex, 10 or more. Directly you can drag createby and its corresponding variable.
    Choose the best approach for your requirement.
    Hope it helps.
    (assign me points)
    Thanks
    Lasya.

  • How can I restrict a vendor with certain value limit?

    Hi Gururs,
    How can I restrict a vendor with certain value limit?.
    Scenario is like this
    If my company was decided to purchase goods from a particular vendor upto Rs.1000, if cross the rs.1000 limit don't allow the Posting the PO and get the Message as warning/error.
    Give the configuration setting's and T.codes
    Thanks and regards
    G.N.Rao

    Hi
    Go to T.Code oms4 and then select the material status BP (Blocked for purchasing)
    Click on Details
    In that under Purchasing select the option A= Warning or B=Error
    Click on Save
    Thus by doing this no further purchasing function for that material can be done. So the PO can not be issued
    So as and when the value limit reaches see that purchasing option is blocked
    So no further PO are generated in the future
    I hope this helps you out
    If found useful reward accordingly
    Thanks
    pavan

  • Minimum Values in Billing Doc - Consolidated Invoice - How to exclude items

    I have a requirement to apply a minimum charge to an invoice but the minimum amount is not to be based on the total value of the invoice.
    The invoice is used to bill a rental contract via a billing plan, via deliveries based on actual usage and other manually entered transactions. All these contribute to the minimum value.
    The invoice is also used to bill other debit notes during the period but their value MUST not be included when the minimum value is to be determined.
    The minimum pricing condition is working as standard SAP, BUT I need to exclude the value of some of the line item. I can distinguish which item are to be excluded by the preceding document type.
    Anyone has any idea of how to do this?
    Regards

    question marked as answered because it is no longer required.

  • 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

  • How to assign a value for Unit of measure (like PC, KG...) in ABAP program?

    Hi,
        How to assign a value for Unit of measure (like PC, KG...) in ABAP program?
        I want to assign PC in a field to execute the program, like wa-ENTRY_UOM = 'pc'.
        But the system returen a message that "Unit of measure  is not convertible to stockkeeping unit PC"
        Could anyone tell me how to assign the value??
        Thanks!

    hi,
    first convert the quantity in the same unit  ( like in you case ST to PC )  by using FM :    MD_CONVERT_MATERIAL_UNIT
    CALL FUNCTION 'MD_CONVERT_MATERIAL_UNIT'
        EXPORTING
          i_matnr                    = matnr
          i_in_me                    = entry_uom
          i_out_me                   = out_uom
          i_menge                    = quantity
       IMPORTING
         E_MENGE                     = fp_l_v_quant
       EXCEPTIONS
         ERROR_IN_APPLICATION       = 1
         ERROR                      = 2
         OTHERS                     = 3.
      IF sy-subrc <> 0.
              give error message here
       ENDIF.
    bcoz in ur program somewhere the quantities etc are compared and there units may be different... so that is why it is showing such error.  so just convert convert the quantity in the same unit  .
    regards
    rahul
    Edited by: RAHUL SHARMA on Jun 17, 2009 9:31 AM

Maybe you are looking for

  • How do I use one audio jack as input and one as output?

    On my MacBook Pro, if I get a USB-headphone connector (to add another audio port), will I be able to set one audio port as input and the other as output? To use the port coming out of the USB jack as a headphone jack, and plug a mic/output device int

  • How do i increase the number of users to my Adobe online

    I currently have one subscription to allow it to be installed on two machines. How do I increase my allowance ? I cant see the ability to change my existing subscription Will I have to repurchase a new subscription rather than add to my existing ? Pl

  • Where is Archived PDF stored in Adobe Database

    For reporting and storage purposes I would like to store the PDFs received by the LiveCycle Server as a part of a workflow. I would like to know where are the current archived PDFs stored ? or what would be the best way to store the PDF (as a PDF) in

  • What is the most recent word on antivirus programs?

    Are Macs still pretty much immune, or should we be considering using an antivirus program; and if so, what?  I know that the word used to be that Mac users didn't need to worry too much but don't know if that still holds true. Thanks, in advance, for

  • Help i locked a device and need to unlock it

    Help My boyfriends I mac pro was on my I phone 5 under devices I erased it can I unlock it?