Calculated measures

     Hi everyone
Hoping that there is an easy workaround to the below
I am calculating GM at a SKU level, however would like to be able to present the data at a product category and/or customer channel level
However when I drag in my calculated field of GM per SKU it recalculates GM at a average product category level and uses that new calc to determine GM achieved, rather than summing the GM per product catergory.
I basically want the GM to calculate at a SKU level but be able to present the data at an aggregate level,
In excel the formulas would look like this:
GM per SKU = ytd sales/ ytd sales quantity
GM achieved for day per SKU = GM per SKU*qty delivered for the day
GM achieved per category = sum(GM achieved for all SKUs in category)
It looks like BO recalculates GM per SKU depending on what product field I drag in ie if my table to calculate GM had product catergory rather than SKU I am getting GM per category, which then impacts my final calculation
I basically want the calcs to keep running at a SKU level but be able to present totals at an aggregate level, rather than aggregating data then calculating GM
Hope this makes sense. Can attched screenshots if required.

Hi,
What you describe sounds very similar to the user guide's definition of the calculation contexts. Read the chapter "Understanding calculation contexts" and make sure that you get to know the input and output calculation contexts:
http://help.sap.com/businessobject/product_guides/sbo41/en/sbo41sp3_ffc_user_guide_en.pdf#page=16

Similar Messages

  • [Forum FAQ] How do I create calculated measure using AMO in SQL Server Analysis Services?

    Introduction
    In SQL Server Analysis Services (SSAS), you can create a calculated measure in SQL Server Data Tool (SSDT)/Boniness Integrated Development Studio (BIDS). Sometimes you may need to create calculated measure by using AMO in a C# or VB project.
    In this article, I will demonstrate so how to create calculated measure using AMO in SSAS?
    Prerequisites
    Before create calculated measure using AMO, you need to ensure that the following components were installed in your server.
    The multidimensional database AdventureWorks Multidimensional Model 2012
    A SQL Server with SSIS and SSAS installed
    The AMO libraries installed:
    X86 Package (SQL_AS_AMO.msi)
    X64 Package (SQL_AS_AMO.msi)
    Solution
    Here is the detail steps to create calculated measure using AMO in SSAS.
    Open SSDT and create a new SSIS project.
    Drag Script Task to the design surface.
    Click SSIS-> Variables to open the Variables window and add two variables that used to connect to the server and database.
    Create a connection to connect to SSAS server.
    Rename the connection name to ssas.
    Double click the Script Task to open Script Task Editor.
    Add Connection and Database variables to ReadWriteVariables textbox and then click Edit Script button.
    Add AMO reference in the Solution Explore window.
    Copy the script below and paste it into the script.
    Dim objServer As Server
    Dim objDatabase As Database
    Dim strDataBaseID As String
    Dim objCube As Cube
    Dim objMdxScript As MdxScript
    Dim objCommand As Command
    Dim strCommand As String
    objServer = New Server
    objServer.Connect("localhost")
    objDatabase = objServer.Databases("AdventureWorksDW2012Multidimensional-EE2")
    strDataBaseID = objDatabase.ID
    If objDatabase.Cubes.Count > 0 Then
    objCube = objDatabase.Cubes("Adventure Works")
    If objCube.MdxScripts.Count > 0 Then
    objMdxScript = objCube.MdxScripts("MdxScript")
    objMdxScript = objCube.MdxScripts(0)
    Else
    objCube.MdxScripts.Add("MdxScript", "MdxScript")
    objMdxScript = objCube.MdxScripts("MdxScript")
    End If
    objCommand = New Command
    strCommand = "CREATE MEMBER CURRENTCUBE.[Measures].[Multipy Measures By 3]"
    strCommand = strCommand & " AS [Measures].[Internet Sales Amount] * 3, "
    strCommand = strCommand & " VISIBLE = 1 ; "
    objCommand.Text = strCommand
    objMdxScript.Commands.Add(objCommand)
    objMdxScript.Update()
    objCube.Update()
    End If
    objServer.Disconnect()
    Then you can run this SSIS package to create the calculated measure.
    Applies to
    Microsoft SQL Server 2005
    Microsoft SQL Server 2008
    Microsoft SQL Server 2008 R2
    Microsoft SQL Server 2012
    Please click to vote if the post helps you. This can be beneficial to other community members reading the thread.

    Thanks,
    Is this a supported scenario, or does it use unsupported features?
    For example, can we call exec [ReportServer].dbo.AddEvent @EventType='TimedSubscription', @EventData='b64ce7ec-d598-45cd-bbc2-ea202e0c129d'
    in a supported way?
    Thanks! Josh

  • Nested IF/AND/OR in Calculated Measure/Column

    I have the following problem, which I couldn't quite solve in Excel and was wondering whether it can be done in PowerPivot (I failed so far):
    A datasheet with a column "HOUR" and another column "AM/PM". Entries in the first column consist of 1,2,3,4,5,6,7,8,9,10,11, or 12, the second column consists of 'AM's or 'PM's. Together they define the time of an incident (regarding the
    below problem, note that I am not allowed to create a new column in the source datasheet or change existing columns). The below formulas 1.) to 3.) work excellent in Excel for getting '1's or '0's for incidents that happened either between 8AM and 4PM, or
    outside of this time window, as long as I create a new column somewhere in the source datasheet.
    1.) =IF(AND(A1>=8, A1<=11),IF(B1="AM",1,0),0) + IF(AND(A1>=1, A1<=4),IF(B1="PM",1,0),0) + IF(AND(A1=12),IF(B1="PM",1,0),0)
    2.) =--OR(AND(A1>=8, B1="AM", A1<>12), AND(OR(A1<=4, A1=12), B1="PM"))
    3.) =--OR(AND(OR(A1={8,9,10,11}),B1="AM"), AND(OR(A1={1,2,3,4,12}), B1="PM"))
    However, I wanted the "1"s to be summarized - without creating an extra column - as calculated field in a pivot table in Excel. As it turned out, the calculated field option in Excel's standard Pivot table doesn't allow such complex formulas.
    Someone then told me to try PowerPivot. However, the calculated column/calculated measure option in the PowerPivot sheet (once I loaded my data) doesn't seem to support the above formulas either.
    The column headers have the same names as I described above. However, some symbols were not accepted so the relevant ones read now: "[HOUR]", "[AM PM]".
    I tried:
    =IF(AND([HOUR]>=8, [HOUR]<=11),IF([AM PM]="AM",1,0),0) + IF(AND([HOUR]>=1, [HOUR]<=4),IF([AM PM]="PM",1,0),0) + IF(AND([HOUR]=12),IF([AM PM]="PM",1,0),0)
    Error: "Too few arguments were passed to the AND function. The minimum argument count for the function is 2."
    =OR(AND([HOUR]>=8,[AM PM]="AM",[HOUR]<>12), AND(OR([HOUR]<=4,[HOUR]=12),[AM PM]="PM"))
    Error: "Too many arguments were passed to the AND function. The maximum argument count for the function is 2."
    Does anybody know how to translate any of the above formulas into one PowerPivot accepts? or, alternatively, any other way how to achieve the desired results? Thank you for any help on this.

    Hi Natrajx,
    The first of your formulas can be translated into the follow DAX syntax that can be used to define a Calculated Column:
    IF(
    table1[HOUR] >= 8 && table1[HOUR] <= 11,
    IF(
    [AM PM] = "AM",
    1,
    0
    0
    +
    IF(
    table1[HOUR] >= 1 && table1[HOUR] <= 4,
    IF(
    [AM PM] = "PM",
    1,
    0
    0
    +
    IF(
    table1[HOUR] = 12,
    IF(
    [AM PM] = "PM",
    1,
    0
    0
    You could also created a Calculated Field based on similar logic using the following formula:
    SUMX(
    'Table1',IF(
    table1[HOUR] >= 8 && table1[HOUR] <= 11,
    IF(
    [AM PM] = "AM",
    1,
    0
    0
    +
    IF(
    table1[HOUR] >= 1 && table1[HOUR] <= 4,
    IF(
    [AM PM] = "PM",
    1,
    0
    0
    +
    IF(
    table1[HOUR] = 12,
    IF(
    [AM PM] = "PM",
    1,
    0
    0
    Note the use of "&&" instead of the AND() function. In DAX, the AND() and OR() functions only support a maximum of 2 arguments. You can use "&&" for the AND operation and "||" for the OR operation. Hopefully
    the DAX examples above will help you to see how it can be applied to your scenario.
    Regards,
    Michael Amadi
    Please use the 'Mark as answer' link to mark a post that answers your question. If you find a reply helpful, please remember to vote it as helpful :)
    Website: http://www.nimblelearn.com
    Blog: http://www.nimblelearn.com/blog
    Twitter: @nimblelearn

  • 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

  • Using named set in calculated measure is not working

    Hi Techies,
    I need an urgent solution. Here is my problem,
    I have a product dimension which has some "n" no of products. I need to create a measure with few members from the product dimension. (e.g. Sales for laptop & mobile explicitly, out of other electronic gadgets)
    I have created a static named set for some n number of products and a calculated measure in which I have included this named set as below,
    CREATE SET CURRENTCUBE.[Compact]
     AS {[Dim Prod].[Gadget].&[Laptop],[Dim Prod].[Gadget].&[Mobile]} ;        
    CREATE MEMBER CURRENTCUBE.[Measures].[Compact Sales]
     AS ([Compact],[Measures].[Sales]), 
    VISIBLE = 1   ; 
    but when I browse the cube the above measure is returning Null value. When I change the named set to dynamic, the measure is showing value but no filters(laptop & mobile) seems to be applied for that measure unless I add that named set explicitly in
    the filter area.
    I need a solution where I don't want to use any filters but the measure should work as expected.
    Please help me with this, it is very urgent.
    Thanks in advance,
    Latheesh
    latheesh

    hi Latheesh ,
    I'm not sure why do you need to create a new measure .. There is a problem to aggregate a set in a calculated member . I will suggest a new member on your
    Gadget dimension :
    CREATE SET CURRENTCUBE.[Others_Set]
     AS {[Product].[Product Categories].[Category].&[4],[Product].[Product Categories].[Category].&[1]} ;        
    CREATE MEMBER CURRENTCUBE.[Product].[Category].[Others]
     AS Aggregate([Others_Set]), 
    VISIBLE = 1   ; 
    select [Product].[Category].AllMembers on 1
    , [Measures].[Internet Sales Amount] on 0
    From [Adventure Works]
    Regards, David .

  • Analytic View activation fails because of a Calculated Measure

    I'm working with HANA SPS02 here.
    Step 1
    I have an Analytic View where I have CALDAY among Private Attributes and VALUE in Measures. I add an Attribute View with UCALDAY (whatever it means) and implement a new calculated measure CALCVAL with logic as follows: if( (date("CALDAY") <= date("ATV_SEL_UCALDAY")), "VALUE", 0). It works fine.
    Step 2
    I added another Attribute View where the key attribute is its own CALDAY field, making a join by that field. Activated the Analytic View failed with the error log as follows:
    Error preparing and executing OLAP column view DDL: SAP DBTech JDBC: [2048] (at 15): column store error: <?xml version="1.0" encoding="utf-8"?><createCubeResult version="1.0"><status><message>The scenario XML is not valid</message><errorCode>2112</errorCode></status><details><errors><detail><element>CalculationNode (finalAggregation) -> attributes -> calculatedAttribute (CALCVAL) -> expression</element><code>46</code><message>Attribute 'CALDAY' is missing in node finalAggregation</message></detail></errors><warnings><detail><element>cubeSchema</element><code>46</code><message>Default language not set. Use 'en'</message></detail></warnings></details></createCubeResult>
    Exception: class com.sap.db.jdbc.exceptions.JDBCDriverException
    com.sap.db.jdbc.exceptions.SQLExceptionSapDB.createException(SQLExceptionSapDB.java:284)
    com.sap.db.jdbc.exceptions.SQLExceptionSapDB.generateDatabaseException(SQLExceptionSapDB.java:149)
    com.sap.db.jdbc.packet.ReplyPacket.createException(ReplyPacket.java:98)
    com.sap.db.jdbc.ConnectionSapDB.throwSQLError(ConnectionSapDB.java:1124)
    com.sap.db.jdbc.ConnectionSapDB.execute(ConnectionSapDB.java:774)
    com.sap.db.jdbc.ConnectionSapDB.execute(ConnectionSapDB.java:639)
    com.sap.db.jdbc.CallableStatementSapDB.execute(CallableStatementSapDB.java:433)
    com.sap.db.jdbc.CallableStatementSapDB.execute(CallableStatementSapDB.java:309)
    com.sap.db.jdbc.trace.PreparedStatement.execute(PreparedStatement.java:153)
    com.sap.ndb.studio.sdk.resource.deployment.bi.DeploymentExecutor.getAndExecuteActivationDDl(Unknown Source)
    com.sap.ndb.studio.bi.deployment.DeploymentJob.activateObjects(Unknown Source)
    com.sap.ndb.studio.bi.deployment.DeploymentJob.run(Unknown Source)
    org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
    Step 3
    If I delete that CALCVAR measure, Analytic View can be activated just fine.
    No hints in OSS Notes so far. Any ideas what went wrong?

    Hello,
    it is extremely hard from such description to figure out what is the problem...
    You might need to paste the screenshots so that we can take a look...
    Just one hint - make sure that you do not take attribute and use it as calculated measure or vice versa - this will definitely lead to error.
    Tomas

  • 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

  • Powerview modifying a calculated measure in SSAS cube

    We are running SQL Server 2012 and Sharepoint 2013 we are having problems with Powerview modifying a calculated measure in the underlying multidimensional cube. We have a powerview report with multiple pages that allows a user to utilize a global filter
    to view the financial performance of particular customers on multiple reports/pages. When the user picks a different customer, one of the calculated measures, in this case gross margin percent, is essentially stuck. It does not change when the customer selection
    changes. It remains the gross margin percent as the previous customer. All of the other measures change appropriately. Measures such as sales, expenses, ebitda and the other measures that are columns in the relational sql server db feeding the cube are fine.
    Only the calculated measures defined in ssas are not working. I then tested the molap cube on a clean connection to a new excel sheet and was shocked to find that the same value the power view report is stuck on is also displayed in the excel file!  It
    has essentially modified the data in the cube!  The only way to clear the value and display the correct calculation is to re deploy the cube. Any one here know what to do to resolve this?

    Hi Osu75,
    According to your description, you create a PowerView report using SSAS cube as the data source in SharePoint site, the problem is that when changing the selection in the global filter, it change the calculated measure in the underlying multidimensional
    cube, right?
    In your scenario, which script are you using when creating this calculated measure?  Generally, report is used to display data from underlying database, it's really strange that the PowerView report change the calculated measure in the underlying multidimensional
    cube.
    From a support perspective this is really beyond what we can do here in the forums. If you cannot determine your answer here or on your own, consider opening a support case with Microsoft. Visit this link to see the various support options that are available
    to better meet your needs:
    http://support.microsoft.com/default.aspx?id=fh;en-us;offerprophone
    Regards,
    Charlie Liao
    If you have any feedback on our support, please click
    here.
    Charlie Liao
    TechNet Community Support

  • 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

  • How to use dynamic set in calculated measure

    Hi, 
    I have this calculated measure in my cube:
    member [Measures].[Estimate]
    as 
    iif(
    isleaf([Calendar].[By Year - Quarter - Month].currentmember),
    iif(
    1=1, // Simplified for examples sake
    [Measures].[Actual],
    [Measures].[Budget]
    sum(
    [Calendar].[By Year - Quarter - Month].currentmember.children,
    [Measures].[Estimate]
    It works fine, however when the user filters on the calendar hierarchy, the totals does not seem to react. As far as I can read, this is related the use of sub cubes when filtering in Excel, and this can be fixed by using a dynamic set, but how? I am unsure
    how one would use it with this measure.
    Thanks in advance

    This used to be a problem with Excel 2003 though I thought it had been fixed with the more recent versions. I've only seen this issue when using named sets in a calculated measure and not when the set is defined within the calculated measure and that's corrected
    by declaring EXISTING before the named set reference as below.
    SET [Member Descendants] AS
    [Calendar].[By Year - Quarter - Month].CurrentMember.CHILDREN
    MEMBER [Measures].[Estimate] AS
    IIF(
    ISLEAF([Calendar].[By Year - Quarter - Month].currentmember),
    IIF(
    1=1, // Simplified for examples sake
    [Measures].[Actual],
    [Measures].[Budget]
    SUM(
    EXISTING [Member Descendants],
    [Measures].[Estimate]
    EXISTING will force the named set to be evaluated with the context of each cell evaluation.
    Martin Mason Wordpress Blog

  • Creating a TEXT calculated measure

    Is it possible to create a calculated measure of data type TEXT using AWM ?
    I want to do the equivalent of defining an OLAP DML formula which returns a text value, but I want to be able to store the formula in the OLAP metadata.
    I'm familiar with creating "dummy" calculated measures in AWM, saving to an XML template file, then editting the XML and reimporting, to define more complex calculated measures than the AWM wizard provides for, but I still haven't been able to successfully create a calculated measure which returns TEXT.
    I've tried changing the XML from DataType="Decimal" to DataType="Text", but there are other sections in the XML such as:
    CalcStep StepClass='oracle.dss.selection.calcStep.SimpleMathCalcStep
    and:
    CalcValue DataType='java.lang.Double'
    which I think are also having an impact.
    Any examples would be much appreciated.
    Thanks,
    Andy White

    I have succesfully created text-valued measures with the AWM graphical interface. You need to make sure when you define the data cube that it does not have the "compressed" option checked, then you will get TEXT as one of the choices of data when you create a measure.

  • Mapping measures in a cube vs Calculated Measure

    I have a fact table as
    Fact_Table_
    Sales Product_ID Special_Product_Flag
    Special_Product_Flag is a y/n flag
    and a Dimension_ table as
    Product_ID Product_Name
    I want to have 2 measures in the cube
    1. Product_Sales
    In the cube I specify the mapping for this measure as Fact_Table.Sales
    2. Special_Product_Sales
    in the cube I specify an olap expression in the mapping as
         case
         when Fact_Table.Special_Product_Flag = 'Y' then Fact_Table.Sales else 0 end
    Now is the measure      Special_Product_Sales treated as a calculated measure ?

    Here are definitions of base versus calculated measures.
    <li> A base measure is a measure that has associated physical storage in the AW. This physical storage is populated using some kind of load step, which may use either SQL or OLAP DML. The measure may then be aggregated according to the aggregation rules of the cube. The value of a base measure for any given cell in the cube may be stored or may be calculated dynamically depending on the "precomputation" rules of the cube.
    <li> A calculated measure is one that has no physical storage in the AW. The values of a calculated measure are always calculated dynamically regardless of the precomputation rules of the cube.
    Your case is clearly a base measure because you are physically loading data into the AW. The fact that you use a case expression in the mapping does not change the fact that is takes up physical storage nor the fact that it can be aggregated. It is the ability to aggregate the data that makes this a useful feature. In your case you will be able to aggregate special_product_sales up the product hierarchy so that its value for 'ALL_PRODUCTS' will be
    select sum(sales)
    from fact_table
    where Special_Product_Flag = 'Y'The value of sales for 'ALL_PRODUCTS', by contrast, would be
    select sum(sales)
    from fact_tableAs a side note it may be better to define your mapping using NULL instead of 0.
    case
    when Fact_Table.Special_Product_Flag = 'Y'
    then Fact_Table.Sales
    else null
    end

  • MDX calculated measure causing performance issue

    The calculated measure below against all product members is causing the excel pivot table to hang indefinitely. Any help on how to optimize the query for better performance?
    SCOPE ([MEASURES].[DIDaysInMonth]);
    THIS = CASE WHEN [Measures].[MonthDifference] < 0 THEN 0
    WHEN [MEASURES].[MonthDifference] >= 0 AND ProjectedEnd > 0 THEN [MEASURES].[DaysRemainingInMonth]
    WHEN [MEASURES].[MonthDifference] = 0 AND ProjectedEnd < 0 THEN
    [Measures].[Ordered Cases] / (([Measures].[Forecasted Sales]-[Measures].[Cases])/[measures].[DaysRemainingInMonth])
    WHEN [MEASURES].[MonthDifference] >= 0 AND ([Time Monthly].[Time Monthly].CurrentMember.PrevMember,[MEASURES].[ProjectedEnd]) <= 0 THEN 0
    WHEN [MEASURES].[MonthDifference] > 0 AND ([Time Monthly].[Time Monthly].CurrentMember.PrevMember,[MEASURES].[ProjectedEnd]) > 0 THEN
    ([Time Monthly].[Time Monthly].CurrentMember.PrevMember,[MEASURES].[ProjectedEnd]) /
    ([Forecasted Sales] / [daysInMonth]) END;
    END SCOPE;
    BI Developer

    Hi Abioye,
    According to your description, you create a calculated measure which against all products  in your AS cube, now the performance is poor when using this calculated measure in EXCEL Pivot table, right? In this case, here are some links which describe
    tips about performance tuning in SSAS, plesae see:
    http://technet.microsoft.com/en-us/library/cc966527.aspx
    http://sqlmag.com/t-sql/top-9-analysis-services-tips
    Hope this helps.
    Regards,
    Charlie Liao
    TechNet Community Support

  • How to create a simple calculated measure ?

    Hello,
    I'm having difficulties creating a very simple calculated measure within OBIEE administrator. Let's say I have a dimension "product" with attribute "product price" and a measure "sales count". I'm trying to define in the "Business Model" layer the calculated measure "total sales". In order to do that I defined it as as a Logical Column with expression "product price" * "sales count".
    However OBIEE doesn't compute what I'm expecting, it does in fact a cartesian product of the products and the grand total sales, which doesn't make sense. To alleviate that I tried to define the measure as associated to the Product level, then I get the computations right but the sales by product are not summed into a grand total.
    Anyway this seems like a very basic thing to do but I've not been able to find any documentation about it; the internal "Help" documentation is extremely limited. Is there another source of documentation that I'm not aware of ?
    Thanks for your help,
    Chris

    Hi there again,
    I'm coming back to you regarding the calculated measure above. As advised, I defined it using physical columns and am - almost - able to get the correct results. However I notice that the measure is not correctly aggregated over the "product" dimension. More specifically what happens is that the products are organized into a level-based hierarchy; only the leaf elements have an attibute "price"; the upper nodes in the hierarchy group different products together with different prices.
    The "total price" measure for such a node should be the sum of "product price" * "sales count" for all underneath nodes in the hierarchy, which is the way it is done for instance in AWM. However with the measure defined as above, I only get NULL values for upper nodes, due to the fact that "product price" is NULL for those levels and thus yields a NULL result.
    I've tried to circumvent the problem by associating the measure to the leaf level of the "product" hierarchy in the Properties -> Levels tab, however this doesn't seem to do what I want, it only forces the computation to happen at the lowest level of the hierarchy. What I would like is for the measure to aggregate to upper levels just as it would were it defined directly in AWM.
    Do you know how to do that ?
    Thanks for your help!
    Chris

  • How do I use the context of the column as part of my calculated measure/column?

    Hello,
    I've struggled with this for a week now.
    I need my calculation to take the context of the column that it's in and use that value as part of a lookup/filter with which to do an operation.
    I basically want to add up the "Value" of all the "ORUs" associated to a Manager(MGR).  But since the ORU's are spread across many managers, I need to calculate the Value
    for an "ORU" and multiply by the "Percent" ( of people that who belong to that ORU for that MGR).   The difficulty is that the MGR(and associated Percent) is one table which is connected via the ORU.  There's no way connection
    to the MGR except by the Column Context.  So, how do I get to it for the calculation? 
    I'd like: CALCULATE(SUM(ORUBUMGR[Percent], FILTER (ORUBUMGR, ORUBUMR[MGR]={This column's header value!})
    pseudo-code would be:
    For each cell in the Pivot table
        SUM
           For each ORU
                  Percent= Look up the multiplier for that ORU associated with the Column
                  SUMofValue = Add all of the Values associated with that Column/Row combination
                  Multiply Percent * SUMofValue
    What won't work is:  CALCULATE(SUM(ORUBUMGR[Percent]), ORUMAP)*CALCULATE(SUM(Charges[Value]), ORUMAP)
    because you're doing a sum of all the Percentages instead of the sum of the Percentages which are only associated with MGR (i.e., the column context)
    The alternatives I can think of is doing a cross join between the tables so you end up with a copy of "Charges" for every row in ORUBUMGR...but while that would work for the example, it
    won't scale as my actual Charge table is quite large.  It'll also end up being quite complicated.  Or, having a column for each MGR where the lookup to the Percent is hardcoded into the calculation...but that also seems complicated and won't scale
    when I want to do future changes. 
    I'd appreciate any assistance...even a "that's impossible".
    Kind Regards,
    Alex
    Link to the XLS on onedrive
    _https://onedrive.live.com/redir?resid=67E698690736D027!3358&authkey=!ADU5F41Sg08Ygm0&ithint=file%2cxlsx
    Link to image showing data and what the pivot answer should look like _http://i.imgur.com/2HC7Lk7.png
    Link to image showing the data model  _http://i.imgur.com/KK3b61v.png
    (I'm waiting to be verified..)

    Yes, you're right, my calculation first attempt only works if the ORU and MGR are on the rows. :(
    I came up with a 2 step calc which is similar to the final calc posted by ImkeF although maybe a little cleaner. It uses a many to many pattern to calculate the ChargeAmt and then a SUMX to iterate over the ORUBUMGR table and apply the percentages.
    ChargeAmt:=CALCULATE(SUM(Charges[Value]),ORUMAP)
    Amt2:=SUMX(ORUBUMGR, ORUBUMGR[Percent] * [ChargeAmt])
    You can roll these into a single measure, you just have to wrap the expression from [ChargeAmt] in another calculate so that it does both the many to many calc and the transition from filter context to row context
    Amt3:=SUMX(ORUBUMGR, ORUBUMGR[Percent] *CALCULATE(CALCULATE(SUM(Charges[Value]),ORUMAP)))
    Personally I think I'd go with the two measure approach (even if you end up hiding [ChargeAmt]) as I think it's easier to read and will be easier to maintain.
    http://darren.gosbell.com - please mark correct answers

  • Constructing Calculated Measures in MDX for different measures using same columns in a fact table

    Hello,
    i have a fact table with 2 columns corresponding to dimensions Dim1, Dim2. In the same table i have 4 other columns Value_Type(int), INT_VALUE(int), FLOAT_VALUE(float), TEXT_VALUE(string). There are a number of measures which are identified by Value_Type and
    depending on their nature could be written in one of the 3 columns (INT_VALUE(int), FLOAT_VALUE(float), TEXT_VALUE(string)) Let's say Measure1 with Measure_Type=1 is age, 2 is account balance and 3 is Name for clarity. There could be other measure types that
    use these 3 same columns for data. So the sample fact table looks like this
    Dim1 Dim2 Measure_Type INT_VALUE FLOAT_VALUE TEXT_VALUE
    10 10 1 25
    10 10 2 2000,34
    10 10 3 John
    10 20 1 28
    10 20 2 3490,23
    10 20 3 Frank
    My task is to write an MDX query for each Dim1, Dim2 combination which returns all 3 measures in the same row. The idea is to construct a calculated member for each Measure that returns value from the right field. For example for Measure1 we take INT_VALUE
    with measure_type=1. The problem is i don't know how to construct MDX query for these calculated members. Can you please help me?
    So my final goal is to write an MDX query that returns all measures in one row for each set of Dim1, Dim2
    SELECT [Measure1], [Measure2], [Measure3] ON COLUMNS,
    NON EMPTY [Dim1].[Dim1].[Dim1].Members*[Dim2].[Dim2].[Dim2].Members ON ROWS
    FROM [Cube]
    Dim1 Dim2 Measure1 Measure2 Measure3
    10 10 25 2000,34 John
    10 20 28 3490,23 Frank

    Hi Kosmipt,
    I would combine the "INT_VALUE", "FLOAT_VALUE" and "TEXT_VALUE" columns into one with STRING data type for the fact table. And there should be one dimension to store the Measure_Type informations. Then in cube, you can write MDX scope for every one of
    "Measure_Type" dimension members. For example,
    scope(
                [Measures].[M]
        [DimMType].[MType].&[1]= CINT([Measures].[M]);                                                                                                                             
    end scope;
    Once the cube is built by the above way, you can write MDX like something like the following to achieve your purpose.
    WITH member [Measures].[Measure1] AS ([DimMType].[MType].&[1],[Measures].[M])
             member [Measures].[Measure2] AS ([DimMType].[MType].&[2],[Measures].[M])
             member [Measures].[Measure3] AS ([DimMType].[MType].&[3],[Measures].[M])
    thanks,
    Jerry

Maybe you are looking for