Calculated measure with condition on 2 date dimensions

Hi,
I built a cube which has 2 different time dimensions, let's say Time1 and Time2 (which both have 2 levels : Year and month), and a measure we'll call measure1.
I would like to define a new measure as a calculated member, that would sum the values of measure1 only where Time1 <= Time2.
Should I write it in SQL, the query would be :
SELECT Sum(measure1)
FROM table
WHERE Time1 <= Time2
Seems to me that it would be an easy thing to do, but as a beginner with MDX I can't find anything that seems to work consistently.
Any help would be appreciated.
Thanks in advance

When you expect to filter time like Time1 <= Time2,  you can do it in MDX if it is from the same dimension and same attribute using the range operator ":".
But when it is different dimension you can achieve the same by filtering members from the dimensions.  Select all members from dimension1 and dimension2 that you want to analyse, no need of creating new measure.
Theoretically speaking member x1 from dimenion1 is not same as member y1 from dimension2 and you cannot filter x1 on the basis of the y1.   
Since I don't know exactly what is your scenario is, alternate approach is as below. It is a sample query, where I am expecting goods to be delivered the same day it is shipped.
with member [measures].[ship date] as Int([Ship Date].[Date].currentmember.Member_Key)
member [measures].[delivery date] as Int([Delivery Date].[Date].currentmember.Member_Key)
member [measures].[late shipping] as iif([measures].[delivery date]>[measures].[ship date],[Measures].[Sales Amount],0)
select {[Measures].[Sales Amount],[measures].[late shipping],[measures].[ship date],[measures].[delivery date]} on 0,
non empty{[Delivery Date].[Date].[Date]*[Ship Date].[Date].[Date]} on 1
from (
select ([Delivery Date].[Date].&[20030713],[Ship Date].[Date].&[20030708]) on 0
from [Step-by-Step])
http://www.bifeeds.com

Similar Messages

  • Batch determination with condition next inspection date is =10

    Hi,
    I want to configure the batch determination in such a way that if next inspection date is <=10 then the batch should not consider in the batch determination at the time of creation of process order, only those batchs should conside whose next inspection date is more 10 days.
    can anyone suggest ,any solution on this .
    Thanks
    HS

    Hi Shaymal & VRMP
    I have checked the system, the only problem I am facing is that the system does not show next inspection date dialog box at the time of UD where I can see the next inspection date being set by the system
    Say, I use QA07 (Triggered Manually) on 19.jan.08. The Next inspection date was 26.jan.08 and Initial Run in Days was 10 (days), the system created inspection lot on 19.jan.08 successfully. At the time of UD it automatically set 29.jan.08 as the next inspection date (i.e. 19.jan.08 + 10 days)  istead of 06. Feb.08 (i.e. 26.jan.08 + 10 days) without showing dialog box / suggesting next inspectino date. 
    regards
    Mobashir
    Edited by: Muhammad Mobashir on Jan 19, 2009 7:11 AM

  • Lag function not working in calculated measure

    I am facing a strange problem while using "Lag" function in calculated measure.
    I have a time dimension which consists of date, workday, financial week, Financial Month and Financial Year.
    The concept of workday is its a integer number which represents date. In case of holidays this number donot change and remain constatnt till next working day. 
    Here workday no remains 460 as 20120708 is a holiday.27 and 28 denotes FinancialWeek.
    Now basically I want to find previous wokdays count.
    with member [Measures].[Prev Count]
    AS
    sum(
              existing [Date].[Workdayno].[Workdayno].Members,
     ([Date].[Workdayno].lag(1),[Measures].[Fact Count]))
    Select { [Measures].[Prev Count]} on 0,
    {[Date].[Calendar].Members} on 1 from [My Cube]
    Where([Date].[Calendar].&[20120709])
    What I expect that It will give me sum of counts where wokday no is 460.
    But its showing null value.
    with member [Measures].[PrevCount]
    As
    SUM(EXISTING [Processing Date].[Workday].[Workday].MEMBERS,([Processing Date].[Workday].LAG(1),[Measures].[Sequenced Records]))
    SELECT {[Measures].[PrevCount]} ON 0 FROM --[E2Eitem]
    WHERE([Processing Date].[E2E Calendar].[Date].&[20120709])
    It looks like existing function is failing to exist the member related to date??
    Any suggestion.

    Try using
    with member [Measures].[Prev Count]
    AS
    sum(
              existing [Date].[Workdayno].[Workdayno].Members,
     ([Date].[Workdayno].currentmember.lag(1),[Measures].[Fact Count]))
    Victor Rocca

  • Date Dimension not updating correctly

    Hi
    My current date dimension underlying data was due to expire soon so I set about trying to create a new one.
    I got hold of the script that it was based and went about re-creating the data like for like.
    I pointed the date dimension at this new data structure and it all processed fine.
    When I was doing some testing I noticed althought the total figures were fine, some of the year figures were a little off compared to the underlying data.
    I found that dates such as 31/12/2012 were being classified as year 2013. The month was also being classified as January but the date was still showing as 31 December 2012
    I switched the date dimension back to the old structure and all year numbers were fine.
    I decided to recreate the Date Dimension in the cube using the same structure as the current date dimension and when it processed with the new data structure all the numbers are correct.
    I tried clearing cache but I am baffled as to why the new data structure won't work with the existing Date Dimension but will work with a newly created date dimension in the same cube?
    Regards

    Hi
    I seemed to have solved it (although I am still testing), there was a data diffrence in the week key and that it was over lapping with the end of the year so I changed it to match what I already had.
    It still doesn't explain that before making the change when I created a new dimension it seemed to work ok.
    I had a look at the XML and the only difference that I could see was that the original date dimension had a Time Binding that was generated on the server or the data source.

  • Naming of multiple Date Dimensions - Logical Layer

    I would like to get some advice on the following:
    I am currently in the process of organizing all the dimensions and facts. During the organizing I have 12 different Date Dimensions. Some facts are join to 6 of those Date Dimensions. With each of the date dimensions, all of them have the same number of columns and names. Therefore, if I am creating a report, carry over the month of Delivery Date Dimension - Calendar Month lets say and Cancel Date Dimension - Calendar Month and then proceed to the results tabs, you will see two columns "Calendar Month" You wont know which one is from the Cancel Dimension or the Delivery Date Dimension. So we have to manually rename them in OBIEE. But I would like to rename them in the BMM/logical layer instead so the end user doesn't have to rename them each time. What I would like to get advice on is how did you implement the naming of multiple Date Dimensions. Cancel Date Calendar Month or Cancel MM etc? I don't want it too long then the column is very wide in the report.
    Any advice is much appreciated!
    thank you,
    Jonathan

    Thank you,
    I read almost every best practice, but not much information around the Date Dimensions, just wondering if anyone has some great ideas around the Data Dimensions?
    Thanks
    Jonathan

  • Single date dimension while creating Aggregate tables

    hi Guys ,
    I have single date dimension(D1-D) with key as date_id and granularity is day-level. I have fact table(F1-D) which gives daily transactions . Now i created three aggregate tables with F2-M(aggregated to monthly),F3-Q(Aggregated to quarterly),F4-Y(Aggregated to yearly). As I said.I have a single date dimension table with date-id as a key.I have other columns month,quarter,year in Date dimension.
    My question is : Is this single dimension table is enough to create the joins and maintain the BMM layer .I have joined the date_id to all the facts in physical layer. In BMM Layer i have one fact and 4 logical table sources .Ii have created dimension hierarchy on Date dimension and created the logical levels as year ,quarter,month and daily level and also set their respective level keys . Now after doing these i have also set the logical levels to the 4 logical table sources in the fact table.
    Here i am getting an error saying :
    WARNINGS:
    BUSINESS MODEL Financial Model:
    [39059] Logical dimension table D04_DIM_DATE has a source D04_DIM_DATE at level D04_DIM_DATE Detail that joins to a higher level fact source F02_FACT_GL_DLY_TRAN_BAL.F03_FACT_GL_PERIOD_TRAN_BAL
    Can anyone tell me why am i getting this error .

    1) as you suggest, creating mini dimension tables for each level
    3) using views with select distinct x,y,z to model 1) but without the need for phsical tables
    I have thought of these scenarios .But it's just creating a multiple Date Dimension tables with there respective grains if we follow 1 and 3 steps you mentioned.
    But i don't want to create aliases or views either on Datawarehouse or physical layer (Admin tool).Just with using a single Date Dimension table I need to comeup with a solution as mentioned by my Colleagues.
    2) pushing all the calendar attributes into the aggreate table (eg your year aggregate has all the year fields, your month aggregate has all the year fields and all the month fields etc.). Then in BM&M use the aggregate table as a logical table source for the date logical table.
    What do you mean by "pushing all the calendar attributes into the aggreate table".If possible can you eloborate a bit so i can try in this way to get this done .
    One morething .Here What they were saying is .Join the Single Date Dimension to all the 4 fact tables in Physical layer . Then drag all the tables into the BMM layer and create a Dimensional hierarchies for the Date dimension with levels as Year -->Quarter--> Month--> day level. With the Fact tables: Single fact tables with multiple logical table sources .Then we need to set the levels on the respective logical table sources with the desired levels .Say monthly aggregate table--> Month, Quarter Aggregate table--> quarter level in the Contents TAB.
    When i do this I am getting the Warning:
    WARNINGS:
    BUSINESS MODEL Financial Model:
    [39059] Logical dimension table D04_DIM_DATE has a source D04_DIM_DATE at level D04_DIM_DATE Detail that joins to a higher level fact source F02_FACT_GL_DLY_TRAN_BAL.F03_FACT_GL_PERIOD_TRAN_BAL

  • Are Cube organized materialized view with Year to Date calculated measure eligible for Query Rewrite

    Hi,
    Will appreciate if someone can help me with a question regarding Cube organized MV (OLAP).
    Does cube organized materialized view with calculated measures based on time series  Year to date, inception to date  eg.
    SUM(FCT_POSITION.BASE_REALIZED_PNL) OVER (HIERARCHY DIM_CALENDAR.CALENDAR BETWEEN UNBOUNDED PRECEDING AND CURRENT MEMBER WITHIN ANCESTOR AT DIMENSION LEVEL DIM_CALENDAR."YEAR")
    are eligible for query rewrites or these are considered advanced for query rewrite purposes.
    I was hoping to find an example with YTD window function on physical fact dim tables  with optimizer rewriting it to Cube Org. MV but not much success.
    Thanks in advance

    I dont think this is possible.
    (My own reasoning)
    Part of the reason query rewrite works for base measures only (not calc measures in olap like ytd would be) is due to the fact that the data is staged in olap but its lineage is understandable via the olap cube mappings. That dependency/source identification is lost when we build calculated measures in olap and i think its almost impossible for optimizer to understand the finer points relating to an olap calculation defined via olap calculation (olap dml or olap expression) and also match it with the equivalent calculation using relational sql expression. The difficulty may be because both the olap ytd as well as relational ytd defined via sum() over (partition by ... order by ...) have many non-standard variations of the same calculation/definition. E.g: You can choose to use or choose not to use the option relating to IGNORE NULLs within the sql analytic function. OLAP defn may use NASKIP or NASKIP2.
    I tried to search for query rewrite solutions for Inventory stock based calculations (aggregation along time=last value along time) and see if olap cube with cube aggregation option set to "Last non-na hierarchical value" works as an alternative to relational calculation. My experience has been that its not possible. You can do it relationally or you can do it via olap but your application needs to be aware of each and make the appropriate backend sql/call. In such cases, you cannot make olap (aw/cubes/dimensions) appear magically behind the scenes to fulfill the query execution while appearing to work relationally.
    HTH
    Shankar

  • Pie chart with two measures and date dimension navigation not working

    Hi Experts,
    Pie chart with two measures and date dimension navigation not working. Any help is appreciated.
    Thanks
    V

    Hi Deepak,
    I had time dimension in the RPD.
    I have stacked bar chart with same time dim like year & month in the report. when I go to legand and set navigation it is working fine. But not with pie chart.
    I am not not sure what is the problem. When I click on Pie chart it is not navigating to the target report. Can it be any other issues..???

  • How to tune performance of a cube with multiple date dimension?

    Hi, 
    I have a cube where I have a measure. Now for a turn time report I am taking the date difference of two dates and taking the average, max and min of the date difference. The graph is taking long time to load. I am using Telerik report controls. 
    Is there any way to tune up the cube performance with multiple date dimension to it? What are the key rules and beset practices for a cube to perform well? 
    Thanks, 
    Amit

    Hi amit2015,
    According to your description, you want to improve the performance of a SSAS cube with multiple date dimension. Right?
    In Analysis Services, there are many tips to improve the performance of a cube. In this scenario, I suggest you only keep one dimension, and only include the column which are required for your calculation. Please refer to "dimension design" in
    the link below:
    http://www.mssqltips.com/sqlservertip/2567/ssas--best-practices-and-performance-optimization--part-3-of-4/
    If you have any question, please feel free to ask.
    Simon Hou
    TechNet Community Support

  • Problem populating date dimension with correct values

    Hi all,
    I have a 'simple' problem, but can't get it solved! The YTD calculations in the cube don't 'reset' at the right moment in time (they should 'reset' on the FISCAL year, but it actually seems to happen on the normal calendar year).
    Our dimensions and cubes are MOLAP. There is a relational table, containing columns with values for both a CALendar hierarchy as well as for a FISCAL year hierarchy. This table populates the date dimension (only the fiscal hierarchy as in MOLAP we only have a fiscal hierarchy). The result looks correct in the data viewer.
    The cube is populated from relational sources as well. One view provides the measure values and the CODE (business identifiers) values for each dimension involved. In case of the date dimension, it provides the code value for the involved level at which we load the cube (month).
    I made a very simple testcase with only 1 dimension (date) and 1 small cube. The cube uses only the date dimesion (to load cube on the fiscal hierarchy at month level) and has 1 base measure that is loaded with a simple number and 1 calculated measure that calculates the YTD value for this base measure. The calculated measure is added in the OWB cube designer using button "Generate Calculated Measures" and choosing the "Year to Date" function.
    When populating the cube and using the data viewer to check the results, the YTD measure values don't 'reset' at the fiscal year end. They seem to reset at the normal CALendar year end!?
    After some testing, I have concluded it has to do with the values I supply to populate the date dimension, but I can't figure out what the modification should be and I can't find any examples anywhere.
    Does anyone out there have a working YTD calculation in MOLAP?
    Any help much appreciated.
    Regards,
    Ed

    Sorry David, I am not sure I've got this right yet. I am looking at using the cumsum function, but I am not sure how to apply this. That is, I can see examples (cumsum(measure, total_dim, reset_dim)), but I think I cannot put such formula directly into the expression editor for a cube measure in OWB?
    Until now I have been using the standard available calculated measures in the OWB measure editor and I think they insert an xml template? I'll get the Excel Calculation Tool from OTN, to see if I can create the correct formula and paste that in OWB in the expression editor for the measure. (Does that tool need a ROLAP workspace or does it need / can it work with a MOLAP workspace?)
    Thanks and regards,
    Ed
    Edited by: EdSp on Jan 13, 2009 1:57 PM
    I have downloaded the Excel sheet and can see how it works, but it seems to "insert" the calculated measures straight into the AW. However we deploy the AW from OWB so I will be looking at getting something to enter/paste in the expression editor of OWB...

  • How to Zero Debt After Account Closure Date in MDX Calculated Measure

    Thanks in advance to anyone who can help me with the below problem.
    I’m building a Finance cube, it holds all customers we have billed and any cash received against their debt. I have a few calculated measures that work out Total Debt, Total Cash. From these I have a calculated measure called Total Debt Outstanding which
    is (Total Debt - Total Cash)
    My problem, when an account is closed the debt is not always zero. We don’t always get all the cash to cover the debt so just write off the outstanding debt. I have a requirement to zero out the debt after closure date has passed. 
    If I look at the calculated measure [Total Debt Outstanding] today for all accounts it will include debt figures from closed accounts, I need the calculated measure
    [Total Debt Outstanding] to ignore this and not to inflate my current debt figure.
    Example
    Account 12345, Debt £3142 added on 15/03/2013, Cash £1,687
    received on 12/12/2013, Total Debt Outstanding £1107. The Account closed on 15/12/2013 with a balance of £1107, after the closure date I need the total Debtor outstanding figure to be £0 if you browse the cube with my date dimension. 
    My date dimension Hierarchies is Year-Quarter-Month-Day
    I have tried using the Scope function to Zero the Total Debt Outstanding figure after closure date but can’t get it to work. 
    My scope calculation is below:
    Scope([Measures].[Total Debt Outstanding]);
    This = IIF([Date].[Year-Quarter-Month-Day].Currentmember > [ClaimData].[Closed].[Closed].Currentmember,0,[Measures].[Total Debt Outstanding]);
    End Scope;
    My Account Opening and Closing dates are in my ClaimData fact table, with Opening Date linked to the date dimension. I can’t link Closing date as we don’t always have a closing date until the account closes, so SSAS errors.
    Many Thanks

    Hi,
    Try compare key value of members. For example,
    [Date].[Year-Quarter-Month-Day].Currentmember.Properties("key") > [ClaimData].[Closed].[Closed].Currentmember.Properties.("key")
    And think about UnknownMember in Date dimension. In this case you can link Closing date
    Best regards,
    Aleksandr Severin

  • TAXINJ WITH CONDITION BASED CALCULATION

    Hi MM Gurus
    We are using TAXINJ procedure for tax calculation with formula base calculation (i.e. tax rates are maintains in J1ID ). As we now that TAXINJ procedure support both condition based and formula based tax calculation. But when I want to use the condition based tax calculation with TAXINJ by maintaining the condition record in FV11, I am getting the tax calculated with formula based only. System is ignoring the condition record maintain in FV11. So please explain how to use the TAXINJ procedure with condition based calculation by maintaining the condition record.
    Reward point will be given please…..
    J K Patel
    Ahmedabad
    Gujarat

    Hi JK,
    if you r using taxinj, then system picks up the rate from J1ID only. if you want to maintain the condition records in FV11 then delete the rates in J1ID. hope this will solve your problem.
    Regards,
    patil

  • Sql query with conditions and calculations???

    Hi,
    how I can build a query with conditions and calculations?
    E.g. I've got this table
    Start          | End     |     Working Place     |     Mandatory
    01-JAN-13 | 11-JAN-13 |     Office           |          1
    14-JAN-13 | 25-JAN-13 |     Home Office      |     0
    04-MRZ-13| 15-MRZ-13 |     Office           |          0
    11-FEB-13 | 22-FEB-13 |     Office           |          1
    Now if column working place=Office and column mandatory=0
    the new column "price" has to calculate: (End-Start)* $25.00
    and if working place=Office and column mandatory=1
    the "price" column has to calculate: (End-Start)* $20.60
    else $0.00
    I tried it with the case statement but I didn't know how
    to calculate my values and display it to the virtual column "price".
    Something like
    case
    when Working_Place = 'Office' and Mandatory=1
         then ...
    else '0.00'
    end as PRICE
    Or is it not possible?
    Edited by: DB2000 on 12.03.2013 05:09

    Use CASE:
    select  start_dt,
            end_dt,
            working_place,
            mandatory,
            case
              when working_place = 'Office' and mandatory = 0 then (end_dt - start_dt) * 25
              when working_place = 'Office' and mandatory = 1 then (end_dt - start_dt) * 20.60
              else 0
            end price
      from  tbl
    START_DT  END_DT    WORKING_PLA  MANDATORY      PRICE
    01-JAN-13 11-JAN-13 Office               1        206
    14-JAN-13 25-JAN-13 Home Office          0          0
    04-MAR-13 15-MAR-13 Office               0        275
    11-FEB-13 22-FEB-13 Office               1      226.6
    SQL> SY.

  • Join With Date Dimension

    Hi,
    I have one Dimension called Caseheader and Date Dimension. In Date dimension I have date key  yyyymmdd format. I have fact table in which i am getting CaseCreationDate from Caseheader Dimension. in case creationdate it contains time as well because
    there is a requirement to do some reports based on timing.
    When I join case creationdate to date column in a data source view with date dimension i do not get any thing  and get error in cube processing as well because it does not match with case creationdate because of time. What is the best possible approach
    to resolve this issue? Do I need to add time dimension? or have a time field in date dimension?
    Could anyone suggest please?
    MH

    Thanks Christian, I have separated date and time and kept the original field with datetime as well in case if somebody wants it for reporting purpose. Thank you so much for all your help suggestions. Much appreciated. Used this code
    convert(date,ch.CaseCreationDate)asCaseCreationDate
    ,convert(varchar(8),convert(time,ch.CaseCreationDate))as[CaseCreationTime]
    Regards,
    Mustafa
    MH

  • Results for % calculation with Condition

    I have a condition on my query in BEx Query Designer that limits the customers shown to ones who have a dollar value in a particular column.  I am now trying to get the results rows to take the condition into account.
    For the dollar key figures, I can just set the results calculations to "Total", and that gives me the total dollars for the customers displayed (that fit the condition), as opposed to the total dollars for ALL customers (if I didn't have the condition).  This is correct.
    However, I have another key figure that represents what percentage of one dollar key figure that another dollar key figure is.  I cannot get the result rows for this key figure to correctly show me the results of the calculation for only the values that match the condition, it keeps showing the percentages based on the full dollar quantities outside of the condition.
    Is there a way for me to get the calculation that I want?
    Query without Condition:
    Customer_____Dollars1_____Dollars2_____%
    A_____________5___________20________25
    B____________10___________20________50
    C____________10___________10_______100
    Result________25___________50________50
    Query with Condition (Dollars1 > 5) Current behavior (wrong):
    Customer_____Dollars1_____Dollars2_____%
    B____________10___________20________50
    C____________10___________10_______100
    Result________20___________30________50
    Query with Condition (Dollars1 > 5) Desired behavior (correct):
    Customer_____Dollars1_____Dollars2_____%
    B____________10___________20________50
    C____________10___________10_______100
    Result________20___________30________66
    Please Help!

    Hi,
    As i cannot see invoice document number in output so would suggest to go for nested exception aggregation.
    Create a new formula and put your aggregated keyfigure inside it and repeat the steps which i told in my last post.
    Make sure to apply it on both the keyfigures.
    If this also not works then last approach would be---
    Make a formula variable with replacement path for customer in replacement path tab choose replace variable with infoobject-replace with attribute value-attribute constant 1..in currency/unit ttab choose number..
    Now multiply your both keyfigure with this formula variable.
    Hope it helps.

Maybe you are looking for

  • How do I remove an apple id account from iphone config?

    Apparently back in the day my daughter bought some songs via iTunes using her own account. My iPod songs/etc on my iPhone came from the instance of iTunes that she used, so I guess there is a blend of songs that I purchased and some that she purchase

  • Multiple instances of Page Flows

    I have a legacy application that I am working on migrating to Weblogic. The legacy application allowed the user to have multiple windows of the same module open at the same time. Users found this useful if they wanted to look at two different records

  • Is there a Flash Player version that works on Vista 64-bit computers?

    Basically, that's the question.  It was working and then there was an upgrade message and I upgraded and now I have had to uninstall flash player and have nothing to use.  Is there going to be a version for Vista 64-bit operating systems?  A lot of w

  • I closed all the taskbars at the top and now I can't get them back.

    I closed all the task bars at the top (so now there is only the blue strip that says 'Firefox - Mozilla Firefox' and the tabs) and now I can't get them back. Tried right clicking everywhere and all the options (right click Firefox in the start menu)

  • BSEG-PERNR not updated

    I am not able to populate/enter the field personnel number  PERNR in the line item (table BSEG) of GL/Vendor, even though the customizing of corresonding posting keys and Field status variant group of GL accounts are showing the field status as optio