How to build MDX query for two periods of time?

I have the following MDX:
SELECT NON EMPTY
[Measures].[Returns],
[Measures].[Returns]
ON COLUMNS,
NON EMPTY
([Employees].[Company].[Company].ALLMEMBERS )
DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME ON ROWS
FROM
SELECT
STRTOSET("[Exec Date].[Hierarchy].[Month Num].&[2014]&[1]", CONSTRAINED)
) ON COLUMNS FROM [cbSales]
WHERE
IIF(
STRTOSET("[Exec Date].[Hierarchy].[Month Num].&[2014]&[1]", CONSTRAINED).Count = 1,
STRTOSET("[Exec Date].[Hierarchy].[Month Num].&[2014]&[1]", CONSTRAINED),
[Exec Date].[Hierarchy].currentmember
Both columns shows returned data for month 2014/01
I want to have data for the next month (2014/02) in the second column.
How can I change the query to achieve my goal.

Hi,
To achieve this you need to create another measure with the help of ParallelPeriod function. Check the following example;
WITH MEMBER [Measures].[Sales Amount Current] AS [Measures].[Sales Amount]
MEMBER [Measures].[Sales Amount Next] AS ([Measures].[Sales Amount], PARALLELPERIOD([Date].[Calendar].[Month],-1, [Date].[Calendar].CURRENTMEMBER)), format_string = "Currency"
MEMBER [Measures].[Current Month] AS [Date].[Calendar].CURRENTMEMBER.Member_Caption
MEMBER [Measures].[Next Month] AS PARALLELPERIOD([Date].[Calendar].[Month],-1, [Date].[Calendar].CURRENTMEMBER).Member_Caption
SELECT {[Measures].[Current Month], [Measures].[Sales Amount Current], [Measures].[Next Month], [Measures].[Sales Amount Next]} ON COLUMNS,
{[Product].[Category].[Category].MEMBERS} ON ROWS
FROM [Adventure Works]
WHERE [Date].[Calendar].[Month].&[2007]&[10]
For ParallelPeriod specify -1 for "Numeric Expression" to navigate forward of the date hierarchy.
Best regards,
Chandima
Thanks, nice answer

Similar Messages

  • How to build sql query for view object at run time

    Hi,
    I have a LOV on my form that is created from a view object.
    View object is read-only and is created from a SQL query.
    SQL query consists of few input parameters and table joins.
    My scenario is such that if input parameters are passed, i have to join extra tables, otherwise, only one table can fetch the results I need.
    Can anyone please suggest, how I can solve this? I want to build the query for view object at run time based on the values passed to input parameters.
    Thanks
    Srikanth Addanki

    As I understand you want to change the query at run time.
    If this is what you want, you can use setQuery Method then use executeQuery.
    http://download.oracle.com/docs/cd/B14099_19/web.1012/b14022/oracle/jbo/server/ViewObjectImpl.html#setQuery_java_lang_String_

  • How to block internet connection for a period of time?

    Hey guys is there a way to block internet connection via a lan connection for a period of time? A program that when my pc is boot up it run secretly and at the time schedule it block the internet connection with no pop up. When i not at home some person
    used my pc to use my internet connection everyday. I can't lock up my pc since my brother or my dad used it.
     

    Hi,
    You could create a schedule task to achieve this.
    The detailed solution please refer to this thread:
    https://social.technet.microsoft.com/Forums/en-US/7544cbed-507d-4eef-907d-bafb99b45411/disable-internet-for-a-set-period-of-time?forum=w7itprogeneral
    Karen Hu
    TechNet Community Support

  • How to build a query dynamically....

    hi...i want to build a query dynamically. i don't want to build query by using string buffer. i want to create it directly by using sql query itself.
    my situation is like this....i have four drop down list in a page. The user can search the things based on one or two or three or four selected values.
    how to build a query for this kind of situation....pls let me know.
    Edited by: success_shiva6mca on Mar 3, 2008 12:39 PM

    there are two problems with building sql directly.
    1. it allows sql injection
    2.it allows XSS
    google them and you will understand if you dont already.
    I will recoment catching the values and using preparedStatements

  • MDX query for to get the data from two cubes

    Hi
    Can you tell me how to create MDX query to get the values from two cubes.  (One hierarchy from first cube and one hierarchy from second cube)
    Can you give me one example.
    Regards,
    Madhu.
    Sudhan

    Hi Sudhan,
    According to your description, you want to retrieve data from two different cubes, right? The short answer is yes. To query multiple cubes from a single MDX statement use the LOOKUPCUBE function (you can't specify multiple cubes in your FROM statement).
    The LOOKUPCUBE function will only work on cubes that utilize the same source database as the cube on which the MDX statement is running. For the detail information about it, please refer to the link below to see the blog.
    Retrieving Data From Multiple Cubes in an MDX Query Using the Lookupcube Function
    Regards,
    Charlie Liao
    TechNet Community Support

  • How to build a query to join on two tables without mapping

    I did Automatic mapping by the workbench Directofield mapping with the table and java object.
    Wanted to build a simple join query by joining on the same field on both the tables.Not the sql query through the toplink using expression builder.
    Please help.............
    Spent one full day for this................

    Thanks Don for the reply,sorry to bug you,but i need help.....
    SELECT A.AGNCY_C,
         A.TYPE_C,
         A.RESN_C,
         A.S_TYPE_C,
         A.SUB_ID_C,
         A.RY_C
    FROM RATING A, REF B
    WHERE A.ID_C = B._ID_C
    AND A.ALPHA_C = B.ALPHA_C
    AND A.EFF_D >= B.MATURITY_D
    This is the real query i was talking about.I did mapping automatically through the workbench,generated java classes also throught the workbench.
    Now they don't want to execute the raw sql.They wanted to get all the RATING objects with the where condition.
    So how to build a query by using toplink.
    tried your example
    ExpressionBuilder builder = new ExpressionBuilder();
    Expression creditRating = builder.getTable("RATING").getField("ID_C");
    Expression issue_ref = builder.getTable("REF").getField("ID_C");
    Expression join = creditRating.equal(issue_ref);
    I am getting java.lang.OutOfMemoryError
    error.
    I selected the option generate classes and descriptors
    from the tables (RATING,REF).,so it created the classes and dscriptors automatically.
    In Database script for the table RATING like this
    ALTER TABLE RATING ADD (
    CONSTRAINT RATING_F1 FOREIGN KEY (ID_C, ALPHA_C)
    REFERENCES REF (ID_C,ALPHA_C));
    I think when i generate descriptor automatically it is keeping this association.
    Please help me.........

  • How to create a calendar for two years in GL

    how to create a calendar for two years in GL

    Hi,
    - Login into Oracle EBS and select a responsiblity with GL Superuser drants (e.g. General Ledger Super User)
    - Navigate to Setup + Financials + Calendars and open the GUI Accounting (Navigation for R12)
    - Query the used calendard (used from jour Set of Books/ Ledger via the GUI
    - Enter for each Period (= Period Type 13, 16, 18,...) one Record, have a look to the existing data, used the same logic.
    In the GUI, defined the calendar for 2 Years
    Dirk

  • How to build a query based on(UNION) 3 vendor InfoObject

    Dear Experts:
    I have a requirement to build one query based on 3 vendor InfoObjct: 0VENDOR + 0VEN_COMPC + 0VEN_PURORG.
    I tried to build a multiprovider upon these 3 infoobjects, but when I Identify(Assign) the key for each InfoObject, supposely there should be 3 InfoObject for me to check (0VENDOR, 0VEN_COMPC and 0VEN_PURORG) so that I can UNION these 3 infoobjects together on vendor number. But since the reference infoobject of these 3 vendor master data is different, I can not check the 3 together.
    Can anybody let me know how to build that query? I only need vendor number show once, and the attributes of 0VEN_COMPC and 0VEN_PURORG can be union to 0vENDOR.
    Any post would be appreciated and thank you all in advance!
    Best Regards!
    Tim

    Hi,
    you can create a link between the vendor objects itself, means link 0vendor with 0ven_compc and 0ven_purorg. This should give you a list of all vendors multiplied with the comp codes multiplied with the purch. org. May be here it is possible to create another link between a attribute (eg. comp_code of 0ven_purorg with comp_code of 0ven_compc). In case it is not possible you need to add this link information somehow. Another option might be to create 2 queries. One on a infoset of 0vendor and 0ven_purorg and another one on 0vendor and 0ven_compc.
    regards
    Siggi

  • How to write sql query for counting pairs from below table??

    Below is my SQL table structure.
    user_id | Name | join_side | left_leg | right_leg | Parent_id
    100001 Tinku Left 100002 100003 0
    100002 Harish Left 100004 100005 100001
    100003 Gorav Right 100006 100007 100001
    100004 Prince Left 100008 NULL 100002
    100005 Ajay Right NULL NULL 100002
    100006 Simran Left NULL NULL 100003
    100007 Raman Right NULL NULL 100003
    100008 Vijay Left NULL NULL 100004
    It is a binary table structure.. Every user has to add two per id under him, one is left_leg and second is right_leg... Parent_id is under which user current user is added.. Hope you will be understand..
    I have to write sql query for counting pairs under id "100001". i know there will be important role of parent_id for counting pairs. * what is pair( suppose if any user contains  both left_leg and right_leg id, then it is called pair.)
    I know there are three pairs under id "100001" :-
    1.  100002 and 100003
    2.  100004 and 100005
    3.  100006 and 100007
        100008 will not be counted as pair because it does not have right leg..
     But i dont know how to write sql query for this... Any help will be appreciated... This is my college project... And tommorow is the last date of submission.... Hope anyone will help me...
    Suppose i have to count pair for id '100002'. Then there is only one pair under id '100002'. i.e 100004 and 100005

    Sounds like this to me
    DECLARE @ID int
    SET @ID = 100001--your passed value
    SELECT left_leg,right_leg
    FROM table
    WHERE (user_id = @ID
    OR parent_id = @ID)
    AND left_leg IS NOT NULL
    AND right_leg IS NOT NULL
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • How to use Batch operation for two xsodata services?

    Hi All,
    I have two xsodata services. How to use submit batch for two xsodata services
    Thanks,
         Mj

    Gateway Batch Calls from SAPUI5

  • How to tune this query for the improve performance ?

    Hi All,
    How to tune this query for the improve performance ?
    select a.claim_number,a.pay_cd,a.claim_occurrence_number,
    case
    when sum(case
    when a.payment_status_cd ='0'
    then a.payment_est_amt
    else 0
    end
    )=0
    then 0
    else (sum(case
    when a.payment_status_cd='0'and a.payment_est_amt > 0
    then a.payment_est_amt
    else 0
    end)
    - sum(case
    when a.payment_status_cd<>'0'
    then a.payment_amt
    else 0
    end))
    end as estimate
    from ins_claim_payment a
    where a.as_of_date between '31-jan-03' and '30-aug-06'
    and ( a.data_source = '25' or (a.data_source between '27' and '29'))
    and substr(a.pay_cd,1,1) IN ('2','3','4','8','9')
    group by a.claim_number, a.pay_cd, a.claim_occurrence_number
    Thank you,
    Mcka

    Mcka
    As well as EXPLAIN PLAN, let us know what proportion of rows are visited by this query. It may be that it is not using a full table scan when it should (or vice versa).
    And of course we'd need to know what indexes are available, and how selective they are for the predicated you have in this query ...
    Regards Nigel

  • How to create sql query for item master with operator LIKE with variables?

    hi all,
    How to create sql query for item master with
    operator LIKE(Contains,Start With,End With) with variables using query generator in SAP B1 ?
    Jeyakanthan

    Hi Jeyakanthan,
    here is an example (put the like statement into the where field)
    SELECT T0.CardCode, T0.CardName FROM OITM T0 WHERE T0.CardName Like '%%test%%'
    The %% sign is a wildcard. If you need start with write 'test%%' and otherwise ends with '%%test'. For contains you need '%%test%%'. You also could combinate this statements like 'test%%abc%%'. This means starts with test and contains abc.
    Regards Steffen

  • Hello. How can I make it so firefox remembers which links I've visited as on the music singles pages for longer periods of time and more links?

    I frequently use the singles pages on wikipedia, for example: http://en.wikipedia.org/w/index.php?title=Category:2012_singles&from=D
    So I had already clicked on the links some months ago on the 2012 singles pages, but firefox forgot that I had clicked on the links there. How can I make it so it remembers for longer periods of time without causing problems to firefox? Also, I want it to remember what links I've clicked on the 2013 singles pages, because I am also keeping up with that. Can I tell firefox to remember all history for these pages, such as 2012 singles, or 2013 singles specifically? I just want firefox to remember what links I've visited, as in, the songs in the 2012/2013 singles pages, and not forget those, because I have already downloaded those so I want firefox to keep track. What are my options? Please let me know, and I hope you understand the problem I am describing.

    My Firefox remembers history from over a year ago, and unless you are using a setting or external tool to clear it, or load huge numbers of pages/download huge numbers of files, Firefox should pretty easily remember links you've accessed in recent months.
    To see what Firefox has computed as the number of URLs to remember, you can check here:
    (1) In a new tab, type or paste '''about:config''' in the address bar and press Enter. Click the button promising to be careful.
    (2) In the filter box, type or paste '''.hist''' and pause while the list is filtered
    (3) Look for '''places.history.expiration.transient_current_max_pages'''
    Mine's set to 104858. I don't know how that was determined.

  • TS3899 How to fix Sent emails getting stuck in Outbox for a period of time before being sent?

    How do you fix Sent emails getting s tuck in Outbox for a period of time before they actually send?
    The error message says that my "sender address is rejected by the server", but it eventually does send.

    Have you tried a Reset [Hold the Home and Sleep/Wake buttons down together for 10 seconds or so (until the Apple logo appears) and then release. When the screen goes blank then power ON again in the normal way.] It is 'appsolutely' safe!

  • How to build ear files for ADF application using Ant task

    How to build ear files for ADF applications using Ant. The ojdeploy ant task can not find application-level deployment profiles. I am trying to automated build and release for ADF application.
    Any help is highly appreciated.
    Thanks
    Shiva

    Hi Timo
    Thanks for your reply.
    I have successfully created ear file using ojdeploy on jenkins. however when am trying to auto deploy using WLDeploy ant task am getting the following
    error :
    weblogic.application.ModuleException: :oracle.mds.config.MDSConfigurationException:MDS-01335: namespace "/oracle/webcenter/quicklinks/scopedMD" mapped to metadata-store-usage "WebCenterFileMetadataStore" but its definition was not found in MDS configuration
    Please advise how to handle this.
    As am a newbie to ADF, could you please advise if it is possible for the ADF application deployments can be automated for different environments using jenkins due to this MDS dependencies.
    Appreciate your help.
    Thanks
    Shiva

Maybe you are looking for

  • BAPI_BILLINGDOC_CREATEMULTIPLE | Result unexpected while automation.

    Hi Gurus, I have created an automation of VF01/02 and create invoice for customer billing. I have created the sales order with reference (VA02) and saved it. Here is my code. *&      Form  GET_SALESORD *       text *  -->  p1        text *  <--  p2  

  • WLS5.1 (SP9) LDAP with JBuilder 4

    JB is great for debugging server-side stuff in WebLogic server, saves loads of time and its a doddle to use so I don't want to lose it. However, recently I've configured LDAP in my WLS which means I need ldaprealms.properties to be in WebLogic's home

  • How to connect to a EAP-MSCHAP network?

    I'm having trouble connecting to my schools network under Arch Linux using netcfg.  Wired internet works well, but I'm unable to connect by wireless as I would under Windows or Ubuntu (using network-manager, which supports MS-CHAP).  The easy solutio

  • Why can't Apple or Itunes make it easy to download music to a. cd

    Why can't apple or Itunes make it simple and easy to download music-songs onto a cd. A few months ago I was able to do this what has happened in the meantime.David

  • Joining a Windows 2000 domain

    Can I join my Sun Solaris 8 server running Samba to a Windows 2000 domain so that all the users that logon or use shares will authenticate thru the domain controllers with their Win accounts? I dont want to create 1500 Solaris accounts.