MDX for Start of Month Values at Daily level

Hey Guys,
I am dealing with a requirement as below, the solution i have is either not addressing the complete problem or is extremely slow and in many cases just not feasible. Need a little help on the same.
Problem: Need a query with cross join of 4 dimension (10 levels) and a date dimension, i need to determine a measures's first
available value across time periods such as Start of month, start of year Etc.. 
I have 
dimA - Level A1
dimB - Leve B1,B2,B3
dimC - Level C1
dimD - LevelD1, D2,D3,D4,D5
Date Dimension - Date, Month, Year as levels.
Measure - M1 To M5
Query: 
SELECT
NON EMPTY
[Measures].[M1]
,[Measures].[M2]
,[Measures].[M3]
,[Measures].[M4]
,[Measures].[M5]
,[Measures].[M1SOM]
} ON COLUMNS
,NON EMPTY
[DimA].[A1].[A1].ALLMEMBERS*
[DIMB].[B1].[B1].ALLMEMBERS*
[DIMB].[B2].[B2].ALLMEMBERS*
[DIMB].[B3].[B3].ALLMEMBERS*
[DIMB].[B4].[B4].ALLMEMBERS*
[DIMB].[B5].[B5].ALLMEMBERS*
[DIMC].[C1].[C1].ALLMEMBERS*
[DIMD].[D1].[D1].ALLMEMBERS*
[DIMD].[D2].[D2].ALLMEMBERS*
[DIMD].[D3].[D3].ALLMEMBERS*
[Date].[Date].[Date].ALLMEMBERS*
[Date].[Month].[Month].ALLMEMBERS*
} ON ROWS
FROM
[Cube]
***The above query has all those cross joins as this query would power an SSRS report dataset.
Need to create a new calculated measure or a real (persisted measure) that displays the Start of month & Start of year Values. Below are the options i have currently. Lets assume, Measure M1 is the one for which i need the SOM and SOY values.
Create a persisted measure (M1SOM) based off the measure M1 and provide an aggregation function of "FirstNonEmpty" : This works perfectly when we run a query at Month level i.e. in the above query have [Date].[Month].[Month].Allmembers instead
of [Date].[Date].[Date].Allmembers. It displays the first available non empty value of the month. However, this means the rest of the measures are aggregated at month level. If i want to display the daily values of the other measures along with SOM values
for this measure it wont work, cause the scope now changes to a single date and i just get the daily value in the M1SOM measure as well.
Create a calculated measure (M1SOM) as below, along with the query above and the same thing happens. Cant display the SOM values at a daily date level.
WITH
MEMBER [Measures].[M1SOM] AS
[Date].[Date].FirstChild
,[Measures].[M1]
3. Create a calculated member as below, This works! however, the query
absolutely kills my machine and takes forever to execute, if i run it with more than 3 levels in the cross join. 
WITH MEMBER M1SOM AS Head(NonEmpty({[Date].[Date].Parent.Children}*[Measures].[M1SOM])).Item(0)
Is there a better way to achieve the SOM and SOY calculations at a daily level?
Thanks
Srikanth

Hi Srikanth,
Basically you want to get the cell values on different granularity for date dimension in the same result set. For performance consideration, we suggest to use MDX to get the 2 types of value separatedly and merge with T-SQL.
Below is an example on how to get data from MDX within T-SQL for your reference.
SET
@mdx
=
'{some
dynamic MDX}' 
SET @sql
=
'SELECT a.* FROM
OpenQuery(LinkedAnalysisServer, '''
+
@mdx
+
AS a' 
BEGIN TRY 
INSERT INTO #result 
EXEC sp_executesql @sql 
END TRY 
BEGIN CATCH 
  IF ERROR_NUMBER <>
'The error number you are seeing' 
  BEGIN 
    RAISERROR('Something happened that was not an empty result set') 
  END 
END CATCH 
SELECT * FROM
#result 
Regards

Similar Messages

  • Reporting monthly values as daily

    I have infocube data like the following:
    fiscper.............qty
    009/2007.........60
    And I need to produce a report like this:
    date................qty
    09/01/07...........2
    09/02/07...........2
    09/03/07...........2
    etc. thru end of month (total qty being divided by number of days in month)
    Being a former abaper, I'm thinking I could manipulate the infocube data into a ztable, and then extract the ztable data into another infocube.  Is there a more standard bw-type approach I should consider?
    Thanks!
    Den

    Hi,
    You can go for Customer Exit, writing simple ABAP code here.I have given the sample code also.Its better to go with Variable exit.
    Customer or Variable exit is done in CMOD transaction. There are 2 kinds of Exit project available for BEX one at the Data target level EXIT_SAPMRSRU_001 and one at the query level EXIT_SAPLRRS0_001.
    check the folloiwng thread for Sample code:
    Re: Customer exit
    check the 3rd option: User exit for Varibales relevant to u.
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/6378ef94-0501-0010-19a5-972687ddc9ef
    http://help.sap.com/saphelp_nw04/helpdata/en/c8/1975cc43b111d1896f0000e8322d00/frameset.htm

  • Requirement for getting the Inventory at a daily level (Non-cumulatvev KF)

    Hello All,
    Kindly provide ur suggesstions on the issue mentioned below:
    We require the Inventory data at a daily level. Also we require that the non-cumulatve Key Figures such as 0TOTALSTOCK, etc. be available to us in the BW itself, since this is required for further processing.
    PS: Right now we are using RSCRM_BAPI to execute the qurey and store the data into a table, but it fails for non-cumulative keyfigures. Kindly suggest if ther are other ways which can suffice the requirement mentioned above.
    Thank you.
    Regards,
    Kunal Gandhi

    Hi Kunal,
    I've just answered your other post about the same issue. You shouldn't open 3 threads with the same question.
    If there is something that is not clear, you can just reply there.
    Regards,
    Diego

  • Last Month value for the keyfigure in Report

    HI ALL,
    how do we get keyfigure value for the last month in the report.
    for ex:  for  amount keyfigure should come for the last month  rest of the key figures should come for the current month values.
    SBU |    AMOUNT (LAST MONTH VALUE) |      QTY(CURRENT MONTH) |     NETPROFIT(CURRENT MONTH)
    The above shown is ex as i required in same manner. Even i restricted with calmonth offset value -1 in keyfigure but it is not working. please help me to get solution .
    Thanks
    Pinky Reddy

    Hi Pinky,
    It is not advisable to use offset to get the previous month value.This is not effective in the case when your current month is Jan & u have to get the previous year's dec month value.It is always better to opt for Exits
    Do use the code mentioned below.
    Note:- ZCUSMFIS3 - Variable in the selection screen for entering current month
               'ZPREVPER - Variable with which the amount key figure has to be resticted.
      WHEN 'ZPREVPER'.
        IF I_STEP = 2. "after the popup
          LOOP AT I_T_VAR_RANGE INTO LOC_VAR_RANGE
                                  WHERE VNAM = 'ZCUSMFIS3'.              
            V_PERIOD = LOC_VAR_RANGE-LOW+4(3).
            V_FYEAR = LOC_VAR_RANGE-LOW+0(4).
            V_FVARIANT = 'B1'.
            V_FISCPERYEAR = LOC_VAR_RANGE-LOW.
            IF V_PERIOD = '001'.
              V_PERIOD = '012'.
              V_FYEAR = V_FYEAR - 1.
              CONCATENATE V_FYEAR V_PERIOD INTO V_FISCPERYEAR.
            ELSE.
              V_FISCPERYEAR = V_FISCPERYEAR - 1.
              LOC_VAR_RANGE-LOW = V_FISCPERYEAR.
            ENDIF.
            CLEAR L_S_RANGE.
            L_S_RANGE-LOW = LOC_VAR_RANGE-LOW. "YYYYMMDD - DD will indicate the no of days
            L_S_RANGE-SIGN = 'I'.
            L_S_RANGE-OPT = 'EQ'.
            APPEND L_S_RANGE TO E_T_RANGE.
            EXIT.
          ENDLOOP.
        ENDIF.
    Hope this provides the solution for your requirement.
    Regards,
    Saswati.

  • Need idea on how to implement this - repeating monthly data on day level

    Hi all, i had run into the following thing, this may soung easy, but i'm searching for the best solution:
    i have a dataset per the stores of the customer, the dataset is an asset count on the end of the specific month. I must not sum the data between two/N months.
    We they need to do several querries like
    sales/assets/day
    Sales/itemgroup/asset/day
    sales/salesperson/asset/day
    etc.
    My problem is that i have this data on a month&store level, but i need to provide a solution, so it could be handled as a "global" value on that, so they can query it "almost any ways".
    I don't really want to generate day/other level data based on this, so any tricks, how to repeat the data in all lines for that specific month on presentation/Business level?
    All ideas are welcome.
    Thanks&Regards,
    D
    Edited by: user8113564 on 2012.09.11. 4:52

    Sorry if I took this wrong but are you try to do level based measured
    Take the same physical column in the fact and have one aggregated at a month level and the other at a day level.
    If yes, make sure you build a date dimension hierarchy and mapped at the correct level to the fact. Then take your measure and correctly define them at the correct level, day, month etc
    This should sort it out

  • Update the profile values at responsiblity level from backend

    HI Team ,
    Find sql for Updating the profile values at responbility level from backend?
    Thanks,
    Chandu

    Please also see:
    How to Change Profile Option Value Without Forms? (Doc ID 943710.1)
    APPS.FND_PROFILE
    http://etrm.oracle.com/pls/et1211d9/etrm_pnav.show_details?c_name=FND_PROFILE&c_owner=APPS&c_type=PACKAGE&c_detail_type=source
    http://etrm.oracle.com/pls/et1211d9/etrm_pnav.show_details?c_name=FND_PROFILE&c_owner=APPS&c_type=PACKAGE%20BODY&c_detail_type=source
    Thanks,
    Hussein

  • MDX - Average of months values for quarters, semesters and years

    Hello,
    I would like to aggregate month values in MDX query to get quarter, semester and year ones.
    The problem is that "SUM" is used by default, but I want the "average" for quarter, semester and year values.
    Example (AVG columns are expected, not SUM ones) :
    Year
    Month
    Value
    sum Q
    avg Q
    sum S
    avg S
    sum Y
    avg Y
    2011
    1
    130,71
    416,58
    138,86
    843,66
    140,61
    1499,33
    136,30
    2011
    2
    146,71
    2011
    3
    139,15
    2011
    4
    133,51
    427,08
    142,36
    2011
    5
    147,14
    2011
    6
    146,43
    2011
    7
    128,58
    373,59
    124,53
    655,67
    131,13
    2011
    8
    109,98
    2011
    9
    135,03
    2011
    10
    135,83
    282,09
    141,04
    2011
    11
    146,27
    2011
    12
    NULL
    Thanks for help.

    Hi Unkedeuxke,
    As Ken said, we do not have a measure Average aggregation type in SQL Server Analysis Services. We do have AverageOfChildren (or Average over time), however it is semi-additive and works only along a Time dimension. Fortunately, we have Sum and Count, and
    since Average = Sum / Count, we can build our own Average aggregation when we need one. Here is a blog about how to create a average measure, please refer to the link below.
    Average Aggregation in Analysis Services
    Regards,
    Charlie Liao
    TechNet Community Support

  • How to get period date of for a given month from a given date in mdx for SSRS report (mm/dd/yyyy)

    I have a situation,  where i need to write expression Period to date(PTD). i want to know how to get the period date. i want you to help in writing Period date or else is there any function to get period date for a given date(the  date is given
    from the parameter dynamically) in MDX for SSRS report
    ram

    Hi ram,
    Per my understanding that you want to get the period date based on the month selected and the given date, right?
    Could you please provide details information below to help us better understanding your requirements, thus we will be more effective to provide an solution:
    What is the format of the period date you want to get, is this date in the DB and you want to filter it based on the month and the given Date?
    Did the month and given date are two parameters in the report? if possible, could you please provide some sample data in the DB and also the snapshot of the report structure
    I assume you want to get the period date(mm/dd/yyy) between the select month(e.g:Feb) and the given date (10/1/2014) and you should get the date between(02/01/2014-10/1/2014).
    If so,and you also have two parameter "Month","EndDate"(EndDate is the given date), please reference to details information below:
    You can create an new parameter "BeginDate" (Date/Time) which is the begin date of the period, you can use the expression to get the value based on the value of the month and the year value from the given date,finally hide this parameter:
    Specify the available value:
    Label:=Parameters!Month.Value &"/01/"& DatePart("yyyy",Parameters!EndDate.Value)
    Value:=CDate(=Parameters!Month.Value &"/01/"& DatePart("yyyy",Parameters!EndDate.Value))
    Specify the default Value:
    Value:=CDate(=Parameters!Month.Value &"/01/"& DatePart("yyyy",Parameters!EndDate.Value))
    Add filter to the dataset as below:
    Preview you will get all the date in the given Period:
    If you still have any problem, please feel free to ask.
    Regards
    Vicky Liu

  • Table for Material Quantity and Value for particular month and year

    Hi All
    My requirement is that for a particular month and year I want to know the stock quantity and stock value for a particular material for a given plant.From which SAP table can I get this data as I want to fetch data for my Y report?
    Regards
    Satish Kumar

    Hi,
    You can use MB5B table as suggested earlier.also you can use:
    MBEW-VMKUM --> stock for previous month period
    MBEW-VJKUM --> stock for previous year period
    PLease view these links which migh tbe helpful to you:
    http://help.sap.com/saphelp_47x200/helpdata/en/39/55fee3bc6111d4b3960050dadf0791/content.htm
    TableStock
    Thanks
    Nisha

  • HT1338 Hi I have an Imac with I5 processor.It was working perfectly and i didnt use for about 2 months.The AC was unpluged.Then week ago when i want to start the Imac, it didnt start.But if i keep holding or pressing the power button for some times then i

    Hi I have an Imac I5 21.5 inch.It was working perfectly.Then i didnt use that for about 2 months. Week ago when i want to start the Imac ,it didnt start.
    When press and hold or keep on pressing the power button then i hear the fans are working and i get a continuous beep( but low freqency tone).
    But screen does not turn on.Please help me to rectify this problem.Best Regards. By the way I am an electronic technician.So if there are any technical things to be done, Pls let me know.I can do it my self.

    Hey terremo,
    Thanks for the question. From the information you provided, it sounds like the iMac is successfully turning on, however video is not displayed. These symptoms can usually be isolated further by the troubleshooting steps in this article:
    Apple computers: Troubleshooting issues with video on internal or external displays
    http://support.apple.com/kb/HT1573
    Thanks,
    Matt M.

  • Creation of a Query to show the values for the current month and the last 12 months data.

    Dear All,
    Good day!
    I have to create a Query with the below requirement.
    I have to create a Query to show the values for the current month and the last 12 months data.
    Can you please guide me how to achieve this ??
    thank you,
    Regards,
    Hema

    Hema
    explain the exact problem..? as you mentioned you want to create query to show values for current month and last 12 months.. so I think you want to show values for 12 months from current data.. you can achive this by multiple way..
    you can have selection screen and field with date .. and restrict based on system current date and 12 months before or you can handle this at your target.. .. I mean there are multiple ways to restrict data by date range..
    for some more hints..
    http://www.forumtopics.com/busobj/viewtopic.php?t=34393&sid=7fba465d0463bf7ff5ec46c128754ed6
    http://businessintelligence.ittoolbox.com/groups/technical-functional/cognos8-l/how-to-display-last-12-months-in-report-based-on-todays-date-3231850
    http://scn.sap.com/thread/3217381
    search on SDN you will get many other ways..
    Thanks,
    Bhupesh

  • How to get the current month value for a customer exit variable?

    How to get the current month value for a customer exit variable? 
    And also if we have an InfoObject with date value (including date, month, year), then how to derive the month value from this date type of Char.?
    Thanks!

    Hi Kevin,
    Check here........
    Re: Customer Exist for "From Current Date To Month End"
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/25d98cf6-0d01-0010-0e9b-edcd4597335a
    Cal month
    Regards,
    Vijay.

  • I have been having issues with not receiving texts and voicemails daily, for a few months now. If I turn the phone completely off, when I turn it back on the messages will flood in from hours before. I can't be continually turning off my phone in case som

    I have been having issues with not receiving texts and voicemails daily, for a few months now. If I turn the phone completely off, when I turn it back on the messages will flood in from hours before. I can't be continually turning off my phone in case someone left me a message. How do I resolve this issue?

    Wifi:  my Cell phone will remember 10 wifi connections.  So delete any you don't use often and your home wifi and try to enter home wifi again.
    if it still won't connect to home wifi, call your internet provider for help.  You may need a newer router or different settings Or upgraded service.   Your phone seeks the best connection and will refuse lesser connections.
    last resort.  Backup the phone.  Do a full reset, then restore as new with the backup.
    if still not fixed, go back to apple and insist on repair or replacement.
    HOWEVER.   voicemail is not a wifi issue, it's a carrier function, which is why the SIM card is a suspect.

  • I'm trying to sync my Iphone 3gs and my home computer has been down for about 2 months.  I have my computer fixed now, and went to update/sync my phone and it tells me "Your apple mobile device service is not started"  How do I fix this?

    I'm trying to sync my phone.  My computer has been down for a few months.  I go to try to sync it today, and it tells me my Apple Mobile Device service is not started.  How do I fix this?  I dont know where to check for what operating system I'm on.

    See Here
    AMDS for Windows
    http://support.apple.com/kb/TS1567
    AMDS for Mac
    http://support.apple.com/kb/ht1747

  • How to Bring the Quarter Period and Previous Month Value for given Input

    Hi to all,
          I want bring Quarter Period and Previous Month value for the given Input. Plz help me on this
    Example :
    Input : 06.2008
    Output:
    Input     Prev.Month  Quarter 1   Quarter 2   Quarter 3 
    06.2008  05.2008      03.2008     12.2007     09.2008
    12.2008  11.2008      09.2008      06.2008    03.2008
      Is there any Standad Exit for this or we have to write coding ?
    Regards,
    Saran

    Hi,
    You can solve this by using Replacement path.There you have a option offsets.Here give the current period.Based on that give the number which previouse month you suppose to want.
    I think this 'll help you
    assign points if this helps
    Regards
    JT Goud

Maybe you are looking for

  • Providing table name dynamicaaly in SQL

    Hi, how can provide table name dynamically in an SQL query. no help of PL/SQL is possible in the scenario. I am trying many possiblities but without any success. any1 knowling please let me know. Regards, Prash

  • Data warehouse modeling

    i am stuck at some of the points and have no clue to what i should do. Please, if you could find it out from someone already there they should know somthing. 1. What do you do with flag indicators and different code attributes in your entity tables.

  • Regarding PDF Generation

    Hi Friends, I am generating PDF. When i am desining Smartform the default Styles is SYSTEM. I this case the PDF is generating. But when i change Styles ( Created in SMATRSTYLES) it is not generating PDF. It is creating PDF file but content is missing

  • Problem with distortion with DAQ Generating Sine wave

    Hello, I have a little problem with my VI who is made for driving a biphased stepper motor: When I change dynamically the output frequency of my DAQ Generaor, I have some weird effect (see picture). It happend progressivelly like this : (the start fr

  • Listener.8li plugin not working with PS CS2 ?

    Dear forum, I tried to compile (Win 2000 / VC7.1 aka Visual Studio.NET 2003) and run the Listener plugin supplied with the PhotoShop CS2 SDK. I opened with VC7.1 the solution file (Listener.sln) and built it. As described in the "Automation tutorial.