Complex Calculations

Hello,
I need to create a calculated measure that is the sum of five fields. I know I can do this by creating three intermediate variables (due to the limitation of only being able to add two numbers together in the standard calculated measures), but is their a better way to do this? I would rather not have a bunch of intermediate measure clogging up what the users see in Discoverer.
Any help would be greatly appreciated.
Thanks,
Carl

You have probably noted that the Calculation Wizard in Analytic Workspace Manager does not offer free from calculations such as Measure_A = Measure_B + Measure_C + Measure_D + Measure_E + Measure F. You have two other methods that you can define calculation: altering the formula of a measure using the OLAP DML and adding the measure through the AW/XML API.
The OLAP DML is the language of the multidimensional engine. The method of using this language to change the equation of a formula is as follows:
1. Create a calculated measure (any calculation) in the appropriate cube.
2. Change the equation using the CONSIDER and EQ commands. Let's say you created the TOTAL_SALES measure in cube UNITS and you want this to be the sum of several other measures. You would using the following command in OLAP Worksheet (which is accessed via AWM's Tools menu).
CONSIDER UNITS_CUBE_TOTAL_SALES
EQ UNITS_CUBE_SALES_B + UNITS_CUBE_SALES_C + UNITS_CUBE_SALES_D + UNITS_CUBE_SALES_E + UNITS_CUBE_SALES_F
UPDATE
COMMIT
Note that the measures are all referenced by their formulas (rather than the variables) in the above example.
To view the altered formula, use the DESCRIBE command. E.g.,
DESCRIBE UNITS_CUBE__TOTAL_SALES
This method is pretty easy. The downside is that the equation does not get carried with any templates you create of the measure, cube or AW. Also, if the physical implementation of the AW (that is, the low level objects that make up the phyiscal model) change, you might need to revisit the measure and make adjustements. Neither of this issues are a big deal - you just need to be aware of tthem.
The other approach is to create an AW/XML template and read it using AWMs Create Custom Measure from Template command (right mouse of Calculated Meaures under cube). A sample follows.
<Create Id="Action1">
<ActiveObject >
<DerivedMeasure Name="TOTAL_SALES" LongName="Total Sales" ShortName="Total Sales" PluralName="Total Sales" Id="UNITS_CUBE.TOTAL_SALES.MEASURE" DataType="decimal" isInternal="false" UseGlobalIndex="false" ForceCalc="false" ForceOrder="false" SparseType="STANDARD" AutoSolve="DEFAULT" ExpressionText="UNITS_CUBE.SALES_B.MEASURE + UNITS_CUBE.SALES_C.MEASURE + UNITS_CUBE.SALES_D.MEASURE + UNITS_CUBE.SALES_E.MEASURE + UNITS_CUBE.SALES_F.MEASURE"/>
</ActiveObject>
</Create>
Note that in the AW/XML XML document all objects are reference to by their logical names.
The advantage to this approach is that the AW/XML api is fully aware of the measure definition and (a) can carry it in AW, cube and measure templates and (b) it insulates you from the physical implementation.
If you try this approach, be aware that the syntax is exacting and that error messages from bad syntax is not easy to interpret.

Similar Messages

  • How do I write JavaScript for a complex calculation in a PDF?

    Is there a way to create a more complex calculation in a PDF? I have created an order form that has separate fields for quantity, price and subtotals. For every item on the order form, the first two quantities are no charge. Each quantity after that is .25/each. How do I write the JavaScript to accomplish this calculation?
    e.g. 6 items ordered, first 2 are No Charge,
    =(2*0.00)+(Qty-2*0.25), should equal $1.00
    =(2*0.00)+(6-2*0.25)
    =0.00+1.00
    =1.00

    Not quite. You still need to use the eval function otherwise the numbers are just strings.
    Try this in the JavaScript Debugger:
    var Qty = 4;
    if (Qty>2) {
        var subtotal = eval ((Qty-2)*0.25);
    } else {
        var subtotal = 0;
    app.alert (subtotal);
    Steve

  • Sap Query sq01: how to combine substrings in complex calculations

    I made a query with sap query. I made 1 local field: name1. I have 2 fields firstname and lastname and a field named class.
    In the complex calculations screen I made the following calculation for that field:
    Condition: CLASS='1'
    Formula: firstname' 'lastname
    When I try to run this query I get an Abap error saying "unable to interpret [firstname] as a number". It looks like the + expression can only be used here for numeric calculations.
    Does anyone know how to solve this?
    Edited by: J S on Jan 27, 2009 11:52 AM

    Hi,
    i think its better to concatenate in the infoset code section.... you create a local filed in infoset of type char and then write the concatenate statement of abap and keep first name and last name in the local field .... write this code in the record processing section and take this local filed and display it in the  query i think this clears you ..
    by the way if you still want any information let me know

  • Need help regarding complex calculation using Max value and limiting data after Max date in MDX

    I am working on a bit complex calculated measure in SSAS cube script mode.
    Scenario /Data Set
    Date
    A
    B
    C
    A+B
    5/29/2014
    Null
    34
    Null
    34
    6/30/2014
    Null
    23
    45
    68
    7/15/2014
    25
    -25
    Null
    0
    8/20/2014
    -34
    Null
    Null
    -34
    9/30/2014
    25
    Null
    60
    25
    10/15/2014
    45
    -45
    Null
    0
    11/20/2014
    7
    8
    Null
    15
    a) Need to capture latest non-null value of Column C based on date
    with above example it should be 60 as of 9/30/2014
    b) Need to capture column A+B for all dates.
    c) Add values from column (A+B) only after latest date which is after 9/30/2014. 
    with above example it's last 2 rows and sum is 15
    d) Finally add value from step a and step c. which means the calc measure value should be = 75
    I need to perform all this logic in MDX. I was able to successfully get step a and b in separate calc measure, however i am not sure how to limit the scope based on certain date criteria. In this case it's, date> Max date(9/30/2014) . Also how should
    i add calculated members and regular members?
    I was able to get max value of C based on date and max date to limit the scope.
    CREATE MEMBER CURRENTCUBE.[Measures].[LatestC] AS
    TAIL( 
      NONEMPTY(
        [Date].[Date].CHILDREN*[Measures].[C]),1).ITEM(0) ,visible=1;
    CREATE MEMBER CURRENTCUBE.[Measures].[MaxDateofC] AS
    TAIL( 
      NONEMPTY(
        [Date].[Date].CHILDREN,[Measures].[C]),1).ITEM(0).MemberValue ,visible=1;
    Please help with Scope statement to limit the aggregation of A+B for dates > MaxDateofC? Also further how to add this aggregation value to LatestC calc measure?
    Thank You

    Hi Peddi,
    I gave TRUNC to both of the dates. But still the same issue. I think the problem is in returning the BolbDomain.
    return blobDomain;
    } catch (XDOException xdoe) {
    System.out.println("Exception in XDO :");
    throw new OAException("Exception in XDO : "+xdoe.getMessage());
    catch (SQLException sqle) {
    System.out.println("Exception in SQL :");
    throw new OAException("SQL Exception : "+sqle.getMessage());
    catch (OAException e) {
    System.out.println("Exception in OA :");
    throw new OAException("Unexpected Error :: " +e.getMessage());
    Thanks and Regards,
    Myvizhi

  • Running complex calculations

    Hi all
    My question has 2 parts
    1) I will need to run a rather complex calculation which involves searching through a rather large dimension (30000 members) and using an allocation % unique to each member, allocate that percentage to other members. So my questions are 1) would this be better in a BSO or ASO cube (my guess is BSO)
    and 2) seeing as the cube will have 10 dimensions and (as I stated earlier) 3 of the dimensions will have large numbers of members, will this calc be time intensive? (I know there are other variables such as server size and speed etc, but I am just looking for a ball park guess right now)
    We are currently using version 11 essbase.
    As always thanks for your expertise

    Hi,
    have you checked the default trace? Do you get a timeout error from the backend? Maybe the calculation is too complex and the iView times out.
    Anja

  • How to select specific rows in rtf template for complex calculation

    Hi,
    I want custom calculation in my rtf template and for this i need to select specific cell's value OR specific row's value. Any one please suggest how can I get this. Below is the example i have plotted using excel. My target is to get field 8 and 9 using sum and minus. We can calculate column over column, is there any way to calculate row over row? If I use variables, then i have to create so many variables because I have more columns and rows to calculate (here i posted one sample table). Any one please help me how can I get expected result other than using variables! If "Using variables" is the only way then also give your valuable opinions.
    Row No
    Curr Qtr
    PQtr1
    PQtr2
    3
    B3
    C3
    D3
    4
    B4
    C4
    D4
    5
    B5
    C5
    D5
    6
    B6
    C6
    D6
    7
    B7
    C7
    D7
    8
    B8=SUM(B4:B7)
    C8=SUM(C4:C7)
    D8=SUM(D4:D7)
    9
    B9=B8-B5
    C9=C8-C5
    D9=D8-D5
    Thanks.

    Hi AlexAnd,
    Thanks for the reply, I got 0 using both codes. This is a dummy table and I plotted 3,4 to give an idea of row number (as like as excel). Rows are individual data sets combining different measures and dimensions with different values.
    Account
    Curr_Qtr
    PQtr1
    PQtr2
    Deposit
    10
    15
    20
    Loan
    15
    20
    25
    Earning
    20
    25
    30
    Assets
    25
    30
    35
    Total
    =SUM(15,20)
    =SUM(20,25)
    =SUM(25,30)
    Expense
    =SUM(15,20)-25
    =SUM(20,25-30
    =SUM(15,20)-25
    Is there any way to identify the range or individual cell's value? Using variables I have to create lots of variables for each cells, I want to avoid that and want to use rows in calculation! Is that possible, Pls share your valuable opinions!
    Thanks.

  • Variable to store a result of a complex calculation in bex query

    Hello all,
    I've got a query in BEX with some key fields to display and also need to perform some calculations not supported in bex formulas.
    I think this could be made in a BEX user exit and I'm trying this by creating a project in CMOD assigning EXIT_SAPLRR0_001... Working with INCLUDE ZXRSRU01 and so on.
    I just want to know if this is possible this way because I execute my query and the variable created never get any value at runtime.
    Could anybody help me or give an idea on how to use BEx user-exits?
    Thank you very much,
    Carlos Hinestrosa.

    Hi!
      I think it should work .here are some links to help topics on using user exits.
    presentations
    https://websmp206.sap-ag.de/~form/sapnet?_FRAME=CONTAINER&_OBJECT=011000358700005475091999E
    Help:
    http://help.sap.com/saphelp_nw04/helpdata/en/e3/e60138fede083de10000009b38f8cf/frameset.htm
    propably they might help you
    With regards
    Ashwin

  • Complex Calculations in Excel 2010 Pivot Tables

    Douglas R. Eckert

    It would be better if you can provide us with more information for this issue....
    In PivotTable reports, you can use summary functions or customer calculations in value field. You can also create your own formulas in calculated fields and calculated items.
    Please refer to:http://office.microsoft.com/en-gb/excel-help/calculate-values-in-a-pivottable-report-HP010382405.aspx?CTT=5&origin=HP005200663

  • How to Handle Large Dumps and Complex Calculations in OBIEE

    Hi,
    We are working on some reports in OBIEE and we are unable to optimize performace. Please consider following scenerios:
    1) Detail Report
    In this particular report we have essentaily data dump. That is there are 5 Dimentions and a Fact table and we are just selecting
    fields from various Dimentions and facts. But the problem is there are over 5000 records. I guess that is making report very slow.
    Another issue is when we click on PAGE Contols, they simply dont work, that is if we click on (>>) to see all records its takes lots
    of time but show only first 25 records. Any idea what is the problem.
    2) Calculated Report
    We have one calculated report where there are 7 calculated columns. Because every column contains different Measures and we have to
    use lots of Filter expressions
    Eg: Filter (Measure1 USING {@VarDate} BETWEEN DIM1.FromDate and Dim1.Todate AND {@VarDate} BETWEEN DIM2.FromDate and Dim2.Todate AND <SOME OTHER FILTERS> )
    The Granuality of data is at employee level and there are around 1388726 records in Fact table.
    Is there is any way to optimize above except to create a summary table instead?
    kindly guide us on above scenerios

    Hi,
    Thanks for your reply, I was trying things suggested, I found that the actual physical SQL (which I can get from "Manage Session" link) run in like 4-5 seconds in Query analyzer but: when I studied SQL carefully it does not contain some fiters which we I have applied in report.
    From example i have a filter in report <Measure.Present = 1 > but in Physical SQL i cannot see that filter. However, the results it gives on dashboard are correct that is after it applies the fillter.
    Any idea why is this happening?
    My guess is because above filter is not being applied at physical sql level thats why query fetches like 20000 recors in server cache and then it applies <Measure.Present = 1 >. Thats why it might be taking time ?
    Please give me your suggestions.
    Thanks !

  • What is advisable for complex calculation fields in ADF?

    Hi,
    I am using JDev 11.1.1.2.0 with ADF 11g.
    I have a screen where user is going to select couple of LOVs. Based on this selection one of my "read only field" should get refreshed.
    This field should actually do calculation based on the 2 fields and another column of a table.
    So for such cases is it advisable to build a function and call this from a binding method OR there is a better way of displaying a calulated field.
    NOTE:
    1. using the expression on a transient field is good if the calculated fields are available in the row. Here I have to fetch a value from a completely different table's column that is not present in the row. Again the value that will be fetched will depend on some other parameter which is available to me in the session
    2. I am looking out to make this generic since these combination of fields are repeated in few of the screens and for same calculations
    Kindly advice the ways in which this can be handled. And pls point the best from your view point.
    Thanks in advance.

    Any quick suggestion?

  • Replace complex calculation as NumberBinding

    I have the following calculation defined:
    public double computePrice(int min, int max, int available, int saturation,
            int productionRate, IPopulationStructure pop, ECityState state) {
        if (available==0) return max;
        if (available>=saturation) return min;
        // The cosine is defined on [0,PI] therefore we must stretch it to
        // saturation and then retrieve the value at the available amount
        double val =  Math.cos(available*Math.PI/saturation);
        // This gives us a value between [-1,1]
        val += 1;
        val *= 0.5;
        // Now between [0,1]
        // Stretch it
        val *= (max-min);
        // place it
        val += min;
        return val;
    I would like the convert this into a bound value, as the input values may change. This means that the int values become IntegerProperty.
    My problem is the calculation of the cosinus on line 7, as there is no equivalent method for NumberBindings.
    How can I achieve my aim to get a Binding, which will change whenever one of the input properties change.

    public DoubleBinding createPriceBinding(final IntegerProperty min, final IntegerProperty max, final IntegerProperty available, final IntegerProperty saturation,
         final IntegerProperty productionRate, final IPopulationStructure pop, final ECityState state) {
         return Bindings.createDoubleBinding(
              new Callable<Double>() {
                   @Override
                   public Double call() {
                         return computePrice(min.get(), max.get(), available.get(), saturation.get(), productionRate.get(), pop, state);
              }, min, max, available, saturation, productionRate);

  • Complex Calculation using sparse lookup

    Hello -
    I am trying to design a model such that it would give me similar result as the query below
    select s.Prod_type, s.prod_code, ROUND(sum(cp.qty*(select cif.factor from index_factor cif
    where cif.factor_type = 'G'
                   and cif.category = s.prod_type
    and cif.type_code = s.prod_code
                   and cif.colour_code = s.prod_col))
    * 100 /sum(cp.qty) , 0 )
    from sale cp, product s where cp.product_id = s.product_id
    So, in the RPD, I created a sparse lookup table to obtain the factor (col F). Created a
    column A = Qty with aggregation as sum,
    column B = Col F * col A
    Column C = 100*Col B/Col A
    In the analysis, I pull the prod type, prodcode, col A, ColB, col C, col F. When I do the aggregation at prodcode, keeping the aggregation rule as default in all the columns, at the totals I would have expected to see in
    Col C= 100*sum(Col B)/sum(col A),
    instead what I get is, sum(Col A) * the factor of the min colour code * 100 / sum(col A).
    note: 1 prod type would have many prod code and one prod code would have many colours.
    Is there any way to achieve as expected.
    Thanks !!
    Edited by: 958402 on 29-Nov-2012 6:43 AM

    Hello !!
    Any help pls !

  • Help with calculations in XMLP Template

    Hi,
    I would like to get some guidance on how the below could be done in XMLP. I am getting the 'Amount' column from FSG and would like to calculate the percentage in the template. Is it possible to calculate rows and store results in column like in the example below in XMLP? Many thanks for your help.
    Type-------Amount-----%
    Gross-----------10-----166.7 (Gross/Net*100)
    Discount---------4-------66.7 (Discount/Net*100)
    ======================
    Net (G-D)--------6-----100.0 (Net/Net*100) or (Gross% - Discount%)

    Hi Hazan,
    I have done a similar Gross Margin Report using XMLP 5.5.
    I have used the concept of variables to store temporary values in my report and carry out complex calculations.
    Please let me know what version of XMLP are you using?
    Some of my form fields containing variables look like this:
    <?xdoxslt:set_variable($_XDOCTX, ’Sum1’, CS_TCOST + CS_TCOST1)?>
    <?xdoxslt:get_variable($_XDOCTX, ’Sno’ )?> <?xdoxslt:set_variable($_XDOCTX, ’Sno’, xdoxslt:get_variable($_XDOCTX, ’Sno’) + 1)?>
    <?xdofx:if(CS_TSELL + CS_TSELL1) <= 0 then
    xdoxslt:set_variable($_XDOCTX, ’Sum1’, 1)
    end if?>
    I am not sure if you are looking at this or not. Do let me know if this solves the purpose and need be required some help :-o)
    HTH,
    Nitin

  • Mod function in Calculator

    Hi everyone,
    in DIAdem script,
    Call Formulacalc("R3 := 0.075671 mod 0.0000001") gives 0
    Call Formulacalc("R4 := 0.075672 mod 0.0000001") gives 1.164.....E-17
    what could be the reason, does it have anything to do with 16 digit precision of floating numbers?
    should i simply assume the values below E-16 as zero?
    thanks in advance
    Kaan

    Hi,
    This is a rounding problem, depending on the precision of the float-values.
    You can't assume every value below 1E-16 to be zero, because this kind of  floatingpoint problems occur typically 14-16 digits behind the first significant digit of your values. If you do calculations with larger numbers, the problem will show up above 1E-16.
    It is hard to tell exactly how large the rounding errors are going to be on complex calculations. There is always the danger of getting much larger errors if very large and very small values are involved in one calculation.
    Example:
    1234567890.1-1234567890 gives 0.0999999046325684
    The roundig error is already dangerously close to the first significant digit of the result. If you do additional calculations with the result, the error can get large enough to produce completely wrong results. In most cases, this is not an issue, but as always, it is a good idea to take care of possible errors.

  • Logical Column(s) a.k.a. Pre-calculated Measures

    I am looking for best practices around logical columns either in Presentation Layer or Business Layer. Specifically I want to know..
    1) Is it advisable to have logical columns?
    2) How many are good to have? Should one create logical columns for all frequent calculations which are done on dashboards?
    3) Are there any performance implications?
    4) Can we use Time Series function with logical columns? Like AGO etc.
    In short I am looking for intelligent pros and cons of such implementations.
    PS: Logical columns are derived from physical columns. For e.g. Profit = Income - Expense.
    Regards.

    Hi
    1) all complex logic should be in the BMM layer in the RPD. Yes, it's advisable to have them in the BMM. Although another good practice is to try to delegate all complex calculations to ETL if possible.
    2) As many as deemed necessary. Yes.
    3) No, not really. But if you use Answers' logical columns - you have to be creative in propagating them to other reports.
    4) Yes you can. But again, this is something that's better to have in the RPD.

Maybe you are looking for