Filters In MDX Statement

I've got an MDX query that I need to add a FILTER to and not quite sure how to accomplish this without ruinging the results of the original query.
Here is the original query:
WITH
SET [Selected Discipline] AS STRTOSET(@Disciplines, CONSTRAINED)
SET [Selected Department] AS STRTOSET(@Departments, CONSTRAINED)
SET [Selected Departments] AS IIF(@Disciplines = @Departments,
FILTER(
DESCENDANTS([Selected Discipline], [Employee].[DISC - DEPT - EMP].[Department], AFTER),
NOT INSTR([Employee].[DISC - DEPT - EMP].CurrentMember.UNIQUE_NAME, "Freelance")),
DESCENDANTS([Selected Department], [Employee].[DISC - DEPT - EMP].[Department], AFTER))
SET [TTM] AS { LastPeriods(12, StrToMember(@SelectedMonth, CONSTRAINED)) }
SELECT
[Measures].[Employee Hours],
[Measures].[Employee Hours %]
} ON COLUMNS,
NON EMPTY CROSSJOIN(
[Selected Departments],
[Employee].[Employee Bill Rate].[Employee Bill Rate].ALLMEMBERS,
[Employee].[Employee Level].[Employee Level].ALLMEMBERS,
[TTM])
DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME ON ROWS
FROM [OLSON BI]
WHERE (
[Employee Hours Time Category].[Time Category].&[Client Facing],
[Employee Hours Time Category].[Utilization Category].&[PRODUCTION])
CELL PROPERTIES VALUE, BACK_COLOR, FORE_COLOR, FORMATTED_VALUE, FORMAT_STRING, FONT_NAME, FONT_SIZE, FONT_FLAGS
I'd like to add this additional filter to the above query:
FILTER ([Employee].[Manager Name].[Manager Name].Members ,
NOT InStr([Employee].[Manager Name].CurrentMember.MEMBER_NAME, "O-Tern")
If anyone can provide any guidance on this, it would be greatly appreciated!
Thanks!
A. M. Robinson

Hello,
Try something like below.
WITH
SET [Selected Discipline] AS STRTOSET(@Disciplines, CONSTRAINED)
SET [Selected Department] AS STRTOSET(@Departments, CONSTRAINED)
SET [Selected Departments] AS IIF(@Disciplines = @Departments,
FILTER(
DESCENDANTS([Selected Discipline], [Employee].[DISC - DEPT - EMP].[Department], AFTER),
NOT INSTR([Employee].[DISC - DEPT - EMP].CurrentMember.UNIQUE_NAME, "Freelance")),
DESCENDANTS([Selected Department], [Employee].[DISC - DEPT - EMP].[Department], AFTER))
SET [TTM] AS { LastPeriods(12, StrToMember(@SelectedMonth, CONSTRAINED)) }
SELECT
[Measures].[Employee Hours],
[Measures].[Employee Hours %]
} ON COLUMNS,
NON EMPTY Exists(CROSSJOIN(
[Selected Departments],
[Employee].[Employee Bill Rate].[Employee Bill Rate].ALLMEMBERS,
[Employee].[Employee Level].[Employee Level].ALLMEMBERS,
[TTM])
,FILTER ([Employee].[Manager Name].[Manager Name].Members, NOTInStr([Employee].[Manager Name].CurrentMember.MEMBER_NAME, "O-Tern"))<o:p></o:p>
DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME ON ROWS
FROM [OLSON BI]
WHERE (
[Employee Hours Time Category].[Time Category].&[Client Facing],
[Employee Hours Time Category].[Utilization Category].&[PRODUCTION])
CELL PROPERTIES VALUE, BACK_COLOR, FORE_COLOR, FORMATTED_VALUE, FORMAT_STRING, FONT_NAME, FONT_SIZE, FONT_FLAGS

Similar Messages

  • How can I get  the MDX-statement which is generated in a query?

    Can I somehow get the MDX statement, which is generated when I create a Query via BeX Query Designer? I am using JCo to connect to BW (3.0b) and to execute MDX statements from a standalone JAVA-application. It would be very helpful to have the statements, so that I don't have to create them by myself.
    If this it not possible...is there any reference regarding the MDX statements, I could use?

    Hi Markus,
    The Query Designer generates no MDX, so you can't find any persisted MDX Statements. But you can do a trick, you can use the SAP BW OLE DB Provider in Excel. This Tool generates MDX Statements check this link:
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/uuid/a06a51f3-0201-0010-8591-b742cfafd267
    I hope this helps.
    best regards
    Kai

  • "Syntax error in the MDX statement " in Process chain failure??Urgent pls

    Hi Experts,
    could any one suggest me the procedure to rectify the below problems in process chain?
    1."Syntax error in the MDX statement "
    2."Error when getting data (Error when getting data (AXI))"
    Rgds,
    BH

    In which case it'll be that Access has a different date format to MySQL, and you're trying to push the string "'25-Apr-12 10:55 PM" into Access, which it's not understanding. To get around this, you need to treat your variable as a true date/time object, rather than a formatted string.
    CFQueryParams should be used on absolutely every database platform, they'll stop your website being vulnerable to SQL Injection attacks for one, which at the moment you're wide open to. Replace your query with something like this:
    <cfquery name="input_comments" datasource="#DSN#" username="#DSNUSER#" password="#DSNPASS#">
          INSERT INTO comments(
                             commenter,
                             comment,
                             datetime,
                             post_id
                   VALUES(
                             <cfqueryparam cfsqltype="cf_sql_varchar" value="#form.commenter#" />,
                             <cfqueryparam cfsqltype="cf_sql_varchar" value="#form.comment#" />,
                             now(),
                             <cfqueryparam cfsqltype="cf_sql_numeric" value="#form.post_id#" /> )
    </cfquery>
    The QueryParams will handle the data types for you, and should pass values around more safely and with fewer issues. Assuming you just want to store the current date and time you don't even need to get ColdFusion involved, as databases have their own functions for this. I believe Access' version is simply NOW(), so I've put that in your query.
    Give the above a go.

  • T-code: RSCRM_REPORT to see MDX statement

    Hi All,
    When you go to T-code: RSCRM_BAPI or RSCRM_REPORT, and when you select a query and in the menu bar you will see "display MDX statement."
    For some reason I cannot see any statement when I do that. Can anyboby tell me how to solve this or is there a way to find MDX Statements ( I know about MDXTEST, RSFLAT, RSCRMMDX)
    Thanks
    Kalyan

    Hello Experts,
    Please share your thoughts!!!
    Kalyan

  • Filter in MDX Statement

    I have a very basic MDX statement which contains a FILTER statement:
    WITH
    SET [Selected Discipline] AS STRTOSET(@Disciplines, CONSTRAINED)
    SET [Selected Department] AS STRTOSET(@Departments, CONSTRAINED)
    SET [Selected Departments] AS IIF(@Disciplines = @Departments,
    FILTER(
    DESCENDANTS([Selected Discipline], [Employee].[DISC - DEPT - EMP].[Department], AFTER),
    NOT INSTR([Employee].[DISC - DEPT - EMP].CurrentMember.UNIQUE_NAME, "Freelance")),
    DESCENDANTS([Selected Department], [Employee].[DISC - DEPT - EMP].[Department], AFTER))
    SET [TTM] AS { LastPeriods(12, StrToMember(@SelectedMonth, CONSTRAINED)) }
    SELECT
    [Measures].[Employee Hours],
    [Measures].[Employee Hours %]
    } ON COLUMNS,
    NON EMPTY CROSSJOIN(
    [Selected Departments],
    [Employee].[Employee Bill Rate].[Employee Bill Rate].ALLMEMBERS,
    [Employee].[Employee Level].[Employee Level].ALLMEMBERS,
    [TTM]) ,
    FILTER ([Employee].[Manager Name].[Manager Name].Members ,
    NOT InStr([Employee].[Manager Name].CurrentMember.MEMBER_NAME, "O-Tern"))
    DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME ON ROWS
    FROM [OLSON BI]
    WHERE (
    [Employee Hours Time Category].[Time Category].&[Client Facing],
    [Employee Hours Time Category].[Utilization Category].&[PRODUCTION])
    CELL PROPERTIES VALUE, BACK_COLOR, FORE_COLOR, FORMATTED_VALUE, FORMAT_STRING, FONT
    When running the query, I get the "Failed to parse the query to detect if it is mdx or dmx".
    THe qqy=uery is basic enough, but for the life of me can't figure out what is wrong????
    Any suggestions woud be greatly appreciated!!
    Thanks
    A. M. Robinson

    I literally have the exact same query running in a different report and it runs fine.
    Also, your FILTER is in a SET statement - mine is not. That is the major difference between my query and yours.
    SELECT
    [Measures].[Employee Hours],
    [Measures].[Employee Hours %]
    } ON COLUMNS,
    NON EMPTY CROSSJOIN(
    [Selected Departments],
    [Employee].[Employee Bill Rate].[Employee Bill Rate].ALLMEMBERS,
    [Employee].[Employee Level].[Employee Level].ALLMEMBERS,
    [TTM]) ,
    FILTER ([Employee].[Manager Name].[Manager Name].Members ,
    NOT InStr([Employee].[Manager Name].CurrentMember.MEMBER_NAME, "O-Tern"))
    If I remove the filter statement from this query and run it WITH the same parameters it runs fine - and has been running fine for literally over a year. The introduction of this FILTER statement is causing an issue.
    So either the filter is in the wrong place or it's not formed properly.
    I can provide a couple of examples of queries that are the ecact same with parameters and run fine, and when a FILTER is introduced they still run fine.
    A. M. Robinson

  • Generic MDX Statement

    Hi!
    What I'm looking for is the MDX equivalent of the SQL statement: "Select * from Table".
    What I want is a generic MDX statement that I can use to get all the measures and dimensions from a Cube or DSO.
    I know it's possible to get all the measures without knowing their names, but I want to know if it's possible to get all the dimensions without knowing their names...
    Any help would be greatly appreciated

    Hello,
    try this:
    SELECT
         [Measures].[ZKEYV01] +the key figures+
    ON COLUMNS,
         [ZCRIT2].[A11] +the characteristic+
         [ZCRIT] +the characteristic+
    ON ROWS
    FROM $ZCUBE  +the cube+
    WHERE (
         [ZCRIT].[000000]
    Here you can find a lot of links:
    http://www.mosha.com/msolap/mdx.htm
    Assign points if helpful
    Best regards,
    Alexander
    And a introduction:
    http://www.mosha.com/msolap/articles/MDXForEveryone.htm
    You can use transaction MDXTEST to test ist.

  • Conditional Filters using case statements

    Hello,
    I have a table view which displays Total Quota and Theatre Quota. Against the Total Quota, there are 2 values - Rollover Revenue and Theatre Revenue. Against the Theatre Quota, there is only Theatre Revenue.
    What I want to accomplish is to display only the Rollover Revenue Aggregated Quarterly number whenever there is a Total Quota number and not display the Theatre Revenue number
    In the table view,
    Year Name     Quarter Name     Quarter Name Sort     Person Region     Quota Name     Quarterly Quota     Credit Amount     QTD Attainment     Credit Type Name
    YEAR-2012     QTR-1-2012     QTR-1-2012     750     Total Quota     6,128,500     5,492,081     89.62%     Rollover Revenue Aggregated Quarterly
                   750          6,128,500     5,344,000     87.20%     Theatre Revenue
         QTR-2-2012     QTR-2-2012     750     Total Quota     5,922,500     5,890,264     99.46%     Rollover Revenue Aggregated Quarterly
                   750          5,922,500     6,120,000     103.33%     Theatre Revenue
         QTR-3-2012     QTR-3-2012     750     Total Quota     5,716,500     0     0.00%     
         QTR-4-2012     QTR-4-2012     750     Total Quota     5,510,500     0     0.00%     
    I used an example in the following link:
    http://oraclebizint.wordpress.com/2008/02/06/oracle-bi-ee-101332-conditional-filters-using-case-statements-in-filters/
    and applied the example in my scenario:
    CASE WHEN Quota."Quota Name" = 'Total Quota' THEN "Credit Type"."Credit Type Name" ELSE 'Dummy' END != 'Theatre Revenue'
    I still get duplicate rows.
    Thanks.

    Could you suggest any solutions for this problem where I can conditionally hide the number only for a certain type of data and not for all type of data?
    Thanks.

  • MDX Statement for TopCountin UniverseDesigner

    Hi together,
    I'm trying to build a TOP N function in a WebIntelligence Document. In a SAP BW Query I've created a formula variable.
    For example the User enters 5 for the variable, so I want to show the TOP 5 of one keyfigure.
    IN SAP BW i can use the condition in the Query to SOLVE it.
    Universes in SAP BO / WebIntelligence doesn't use conditions from the query.
    Can anyone help me to build a MDX-Statement in the Universe Designer to get the TOP N of a keyfigure.
    Thanks a lot!
    Kind regards
    Lars

    Hi Ingo,
    thanks for your fast reply.
    I found the document and I think I'm near a solution.
    My current MDX statement generated from the universe is:
    WITH MEMBER [Measures].[24145E65-73A0-DF11-85,88,14,60,A,C,0,0] AS
    TOPCOUNT([0ME_MED_ISS].[LEVEL01].members,3,Measures].[26SDIBEB571NMBEOG191RX7OO])
    SELECT  {[Measures].[26SDIBEB571NMBEOG191RX7OO],  [Measures].[24145E65-73A0-DF11-85,88,14,60,A,C,0,0],
        [Measures].[EQAO129PIC9UWXOJ2W2KRLANC] }  ON COLUMNS ,
    NON EMPTY UNORDER( {[0DIVISION].DEFAULTMEMBER} )  ON ROWS
    FROM [ZSDAMP004/ZSDAMP004_S004]
    SAP VARIABLES [Z1PME003] INCLUDING [0DIVISION].[40] [Z1PME003] INCLUDING [0DIVISION].[22] [Z1PME003]
    INCLUDING [0DIVISION].[21] [Z1PME003] INCLUDING [0DIVISION].[20] [Z1PME003]
    INCLUDING [0DIVISION].[00] [Z1PEI036] INCLUDING [0PLANT].[9010] [Z1PIN030]
    INCLUDING [0CALMONTH].[200906] : [0CALMONTH].[201008]
    [ZFV010] INCLUDING 2
    The Problem is the  Statement:
    WITH MEMBER [Measures].[24145E65-73A0-DF11-85,88,14,60,A,C,0,0] AS
    TOPCOUNT([0ME_MED_ISS].[LEVEL01].members,3,[Measures].[26SDIBEB571NMBEOG191RX7OO])
    if I use the statement in the one above and use the transaction mdxtest in bw:
    WITH MEMBER [Measures].[24145E65-73A0-DF11-85,88,14,60,A,C,0,0] AS 1 it works fine.
    My declaration in the univese for the TOPCOUNT is:
    <EXPRESSION>TOPCOUNT([0ME_MED_ISS].[LEVEL01],3,[Measures].[26SDIBEB571NMBEOG191RX7OO])</EXPRESSION>
    The Error for the statement is: "Invalid MDX command with ,"
    Thanks a lot.
    Lars
    Edited by: Lars Ohm on Aug 5, 2010 12:32 PM

  • Problem with mdx statements generated by CR

    Hello Experts,
    we have a problem concerning mdx-statements produced by Crystal Reports.
    We have built a report upon a query with a variable. Now within one Designer, the generated mdx statement looks like this:
    SELECT {[Measures].[4LPEKDIGEPNC4ENQA7Z0TN7MH]} ON COLUMNS FROM [MC_CO2010/C_BO_BSDB_1] SAP VARIABLES [ZKS__MSM] INCLUDING "432140" : "432140"
    Within another installed designer (same version etc.), the statement looks like this:
    SELECT {[Measures].[4LPEKDIGEPNC4ENQA7Z0TN7MH]} ON COLUMNS FROM [MC_CO2010/C_BO_BSDB_1] SAP VARIABLES [ZKS__MSM] INCLUDING [KSTL].[432140] : [KSTL].[432140]
    And only this version shows the data !
    Personally I know only statements like the last one (variable values in brackets). But only the first one (variable values in double quotes) does work. Does anyone know the reason for this ? How can we then achieve that the CR designer produces statements like the first one ?
    Thanks for your help in advance,
    Frank

    We´ve solved the problem:
    I discovered that on the computer that generated the "" statement, only CR2008 with SP3 was installed. Wheresas on the pc that generated the -statement, SAP Integration Kit (SIK) CR2008 SP3 AND SIK CR2008 Fixpack 3 was installed. So I de-installed SIK CR2008 Fixpack 3 and then both machines generated the same statements with the "".
    @Ingo:
    No, both values had been entered manually, so there was no difference in this. As I wrote above, the only differences where the addionally installed FP3.
    Noneheless, the mdx-statement with the "" seems strange to me. Is this something official ? If I take a look at the description for BW-Specific Enhancement for MDX:
    http://help.sap.com/SAPhelp_nw04/helpdata/en/a7/18533d6dd60610e10000000a114084/content.htm
    the seem to be ok and it is also the way I am used to it.

  • How to Generate a MDX statement using a BEX query

    Hello,
    Is there any possiblity in BW to generate a MDX statement using a BEx query?
    Thanks,
    Ravi

    BW does not generate any MDX statement for Bex query.I have tried ample number of times to acheive this but failed.
    Like an Infocube the Query is also an object where in you can write MDX queries on BEx Queries.
    As it is I never found BW rendering MDX queries.But with MDX queries you can get something but how far it helps I don't know.
    RSCRM_BAPI is obsolete and it is recommended to use RSCRM_REPORT somewhere I have read ,but when I went to that transaction I never found that "MDX" button at all.
    It was converted to "OLAP Check" which gave me some warning on the key figures and that's it.
    Somehow I feel BW is not comfortable with MDX.
    Regs
    Gopi

  • SAP MDX statement size limit ???

    Hi all,
    we are developing complex stuff with MDX and now the question comes up, if there is any limit in the MDX statement size in SAP Abap world. The main handler classes are CL_RSR_MDX_COMMAND, CL_RSR_MDX_OLAP_REQUEST does anyone here know if there is a limit in the MDX statement size ???
    Thx a lot !

    Not sure on the MDX but from a OLAP statement point of view - a straight SQL against an Oracle tablehas a limit of 32k and in unicode 64k
    I am seeing some interesting scenarios when SQLs are fired through the application and not direct..
    A select with multiple in clauses will first try and do a between on the SIDs - if that fails it will build an in clause..
    On the phsical level the SQL is partitioned up and fired mutliple times (obviously to get aroudn the 32k/64k limit)
    However in a virtual cube scenario - a function module can only call 200-250 (hard coded!) statements on an in clause - you can override this but risk a database error on too long a SQL statement..
    THis may or may not help.. but it's all background

  • Filter Function in MDX statement

    Hi Experts,
    I have a question on MDX, i hope this is the right place to post.
    I want to exclude a certain value of an infoobject in MDX output. How can i achieve this?

    Though not recommended for huge sets - are you not able to use things like not equal or not in list in your query filters?
    Anyways google " OLAP universes best practices" - its a good document

  • Set in Excel using ORDER MDX statement not showing correct results on PowerPivot model

    I have defined a set in Excel 2013 with this syntax: 
    order(Topcount([Company].[Company].[Company].members,
    10,
    [Measures].[Sum of TotalValue]),[Measures].[Sum of TotalValue]
    ,DESC)
    The order statements is not properly Applied. Order by name is still active. Would appreciate your help, if have I done something wrong or is this a bug?

    Ok in the meantime I have solved this myself. In the field settings is an option for "Automatically order and remove duplicates..." which is turned on by default and overrules specific order statements in the set. I am not quite sure why but as long as
    you know about it, this can be addressed by turning off.

  • Generate a Sales report filtered by US State

    I need to generate a sales report by US state. Currently, I don't even see "state" as a data point on the sale reports. What can I do to make this work?

    Hi Antonio,
    Personally I would add two sales stage fields to your report. Make one of them a BIN, e.g. go to column formula and select "BIN"... Then create two groups 1 for Wons and the other for Active. The code works out something like this:
    case WHEN "Historical Sales Stage"."Sales Stage" IN ('2: Initiate Relationship', '3: Assess and Evaluate Needs') then 'Active' WHEN "Historical Sales Stage"."Sales Stage" = 'Closed/Won' then '' else "Historical Sales Stage"."Sales Stage" end
    You put a prompt on this field where the user can select whether they want to see Won/Active if they want to see all they just skip the prompt, any use to you?
    Oli @ Innoveer

  • Challenge for MDX Experts: help me fix my MDX statement

    How do you select based on a wild card (*).
    How do i fix my following select statement where the line is <b>[ZSOFUND] INCLUDING "*2004D"</b>
    SELECT
    [Measures].MEMBERS ON AXIS(0) ,
    NON EMPTY [0FUNDS_CTR__0BUS_AREA].MEMBERS ON AXIS(1)
    FROM [xxxxxxxxx]
    SAP VARIABLES [ZCENTER] EXCLUDING "01"
    [ZSOFUND] INCLUDING "*2004D"
    [0S_FYEAR] INCLUDING "2004":"2005"
    [ZUPNFUN] INCLUDING "103"
    [ZUPNFUN] INCLUDING "104"
    Message was edited by: Prakash  Singh

    HI,
    see the coding in bold as well
    You need to declare the line type for appending
    DATA : ra_ekorg TYPE ty_ra_ekorg,
    TYPES:  ty_ra_ekorg  TYPE RANGE OF ekorg,  "Type range for Pur Org
    PERFORM f_authchk_ekorg  USING s_ekorg[]
                            CHANGING ra_ekorg[].
    FORM f_authchk_ekorg  USING    fp_s_ekorg    TYPE ty_ra_ekorg
                          CHANGING fp_ra_ekorg   TYPE ty_ra_ekorg.
    <b>*Local types
      TYPES: BEGIN OF l_ty_ekorg,
             ekorg TYPE ekorg,
             END OF l_ty_ekorg.
    *Local range
      DATA: l_ra_wa_ekorg LIKE LINE OF fp_ra_ekorg.
    </b>
            l_ra_wa_ekorg-sign = 'I'.
            l_ra_wa_ekorg-option = 'EQ'.
            l_ra_wa_ekorg-low = '102'.
            APPEND l_ra_wa_ekorg TO fp_ra_ekorg.
            CLEAR l_ra_wa_ekorg.
    ENDFORM.  
    hope I am not wrong with your query
    reward if useful
    feel free to post if any doubt
    regards,
    nazeer

Maybe you are looking for