How to calculate Average using Dimension Formulas  or Default Logic

Hello
I am trying to calculate the average without success. Do you know how I can Achieve the following? :
We have multiple u201Cofficesu201D in the ENTITY dimension that fall under a Region. Let´s say 400+ offices under 20 Regions
For example:
Region1
   Office A
   Office B
Region2
   Office C
   Office D
   Office E
We have an Account named 'SalesUnits', and I am looking to get an Average Sales by Region and then be able to compare one Office against the Average of the REGION it belongs to.
So If I have:
                            Sales Units
Office C                   20
Office D                   10
Office E                   15
Average of Region 2 would be 201015/3 =15
But the number of office is variable, Sometimes I can have more offices.
So I will have to count the number of offices that belongs to that region.
I need this average so every office can compare their sales against the Region Average.
Do you know how I can do this? I have tried some MDX syntax but without sucess.
Thanks in advance!
Anna

Hi Anna,
  This will need to be done in Dimension logic as I assume, you;'d like to have the average up the region heirarchy.
I'd suggest having 3 accounts for this
ID .....................................FORMULA
SALES_UNITS...................
OFFICE_COUNT.................1
UNITS_AVEREAGE............SALES_UNITS/OFFICE_COUNT
The formula bit, goes in the formula column. When look at office count against the region heirarchy, it will sum up the 1's thereby giving you the denominator for the formula and you'll get the avereage up the region heirarchy.
Tim

Similar Messages

  • Dimension Formula versus Script Logic that runs on default

    Hi Experts,
    Which is better to use dimension formula or script logic that runs on default? We have a lot of dimension formulas and when noticed that it has a huge impact in the performance of our AppSet. When we try to remove them, the performance seems better. We we're thinking of transforming these dimension formulas into script logic which will run by default instead. Right now I'm hesitant with two things, 1.) Will there be improvement in performance if I all these formulas are run at default via script logic? 2.) The maintenance seems to be much more complex for the user if we use script logic.
    Thanks,
    Marvin

    Hi Marvin,
    Actually you pointed very well the advantage and disantavage regarding dimension formula.
    Dimension formula are executed into run time which means that value are not calculated. Of course this will have an impact regarding performances.
    Usually our recommendation is to use dimension formula just when yoiu have KPI's to calculate which will be very difficult to be implemented into SQL scrip logic or when you have very simple calculation like Account A = Account B+ Account C.
    For other calculation we advice our customer to use script logic.
    But attention:
    Default formula should not become very heavy because you will arrive into other issue with performances.
    When you will send data if default formula script will be heavy you will arrive into situation to wait may be minutes just to send one figure and of course this will be not acceptable for users.
    So you have to use script logic but you have to run into batch mode (schedule package) that script logic.
    Into default formula you have to keep just minimum (you have to calculate just figures which have importance for user imediat, real time).
    Also you have to be aware that moving dimension formula into scrip logic actually your fact table will grow a lot because the number of records generated will be probably 3-4 times bigger than number of records from fact table with dimension formula.
    Maintenance of script logic is more complex than dimension formula and you pointed very well this.
    So it is a balance and I tried o provide you suggestions or best practice when you have to use dimesnion formula and you have to avoid dimension formula.
    I hope this will help you to arrive to best combination for your application.
    Kind Regards
    Sorin Radulescu

  • How to calculate Average balance for an account

    Hi,
    How to calculate average balance for an account for a particular period say for JAN-12 period and after the end of that period for another two days 01-feb-12 and 01-feb-12 ?
    I'm using the following query :
    SELECT cc.segment1||'-'||cc.segment2||'-'||cc.segment3||'-'||cc.segment4||'-'||cc.segment5||'-'||cc.segment6 "Account_XX",
    nvl(sum(l.accounted_dr - l.accounted_cr),0) "Balance"
    FROM gl_code_combinations cc,
    gl_je_lines l
    WHERE cc.code_combination_id = l.code_combination_id
    AND l.set_of_books_id ='XX'
    and code_combination_id = replace it with code combination_id for account_xx
    AND l.effective_date <= '31-Jan-12' (january period end ??)
    GROUP BY cc.segment1||'-'||cc.segment2||'-'||cc.segment3||'-'||cc.segment4||'-'||cc.segment5||'-'||cc.segment6
    There are some discrepancies in "average balance" after end of month (Jan-12)?
    How to calculate average balances for a particular account (Account_XX above)from end of month of Jan to first two days of february?
    Thanks,
    Kiran

    Kiran,
    Please let me know first, is Average Balancing feature enabled in your GL Ledger?
    Regards
    Muhammad Ayaz

  • Using Dimension Formulas to sum data based on different criteria

    Hi all,
    I am trying to use a u201CDimension Formulau201D to perform the following calculation:
    We have an account dimension which has 2 important properties:
    1.     CRITERIUMTYPE: This property can have 3 different values: u201CWERKu201D, u201CINVu201D OR u201CLIQu201D
    2.     ACCTYPE: This property can have 2 different values: u201CEXPu201D or u201CINCu201D
    The client wants to have a report that sums data based on these 2 properties. An example will help to clarify this:
    ACCOUNTS     CRITERIUMTYPE     ACCTYPE     VALUE
    ACCOUNT A         WERK                          EXP               100 u20AC
    ACCOUNT B         WERK                          INC               150 u20AC
    ACCOUNT C         WERK                          EXP               200 u20AC
    ACCOUNT D         WERK                          INC               300 u20AC
    ACCOUNT E         INV                          EXP               50 u20AC
    ACCOUNT F         INV                          INC               100 u20AC
    ACCOUNT G         INV                          EXP               200 u20AC
    ACCOUNT H         INV                          INC               500 u20AC
    The clients wishes to see this data in the following way:
    CRITERIUMTYPE     ACCTYPE     VALUE
       WERK                         EXP              300 u20AC
                                        INC              450 u20AC
       INV                         EXP              250 u20AC
                                     INC              600 u20AC
    In order to achieve this I have created several new accounts, one for each combination e.g.: Account WERKEXP is used to sum the data on the combination CRITERIUMTYPE=WERK and ACCTYPE=EXP. I have created a dimension formula in my account dimension but this is where I am stuck. I have created the following formula to calculate the account WERKEXP:
    IIF([BUDGETPOSITIE].CURRENTMEMBER.PROPERTIES("ACCTYPE")="EXP",IIF([BUDGETPOSITIE].CURRENTMEMBER.PROPERTIES("CRITERIUMTYPE")="WERK",[BUDGETPOSITIE].CURRENTMEMBER,0),0)
    The problem with this formula is the following:
    The formula will add all amounts that meet the 2 criteria mentioned in the formula, EXP and WERK, but as soon as it finds an accounts that does not match the 2 criteria it will set the account WERKEXP back to 0. I need to know if there is a way, using dimension formulas, of adding these values together without the new account being set to 0 as soon as one of the accounts it needs to check does not meet 1 of the 2 criteria.
    We are working on SAP BPC 7.5 for NW with SP04
    All help is very much appreciated!
    Kind regards,
    Stefano

    Hi,
    You can also use ParentHn property to have different grouping of accounts within the dimension.
    So in your case rather using the member formula you can have four accounts and add them in the Parenthn property for grouping it.
    1. The Solution proposed by Nilanjan is specific for a Report/IS and Performance will be good
    2. My solution will be global something similar to MDX formula, but performance may be slightly lesser than using excel function.
    Hope this helps,
    Regards,
    G.Vijaya Kumar

  • How to calculates averages and send to a file?(source code)

    how to calculates averages and send to a file?(source code) I need to get started but I don't know where to begin...........the book I have doesn't really say how to handle averages and send to a file.................anybody got suggestions on how to get started? I am a newbie so place in layman's terms.............thanx

    To calculate an average: add all of the numbers together and divide by how many numbers you added together.
    ex: (1 + 2 + 3 + 10)/4 = 4 (4 is the average)
    As for writing them to a file, look over the API for random or sequential access files.

  • How to calculate average not through basic formula

    Can any bodytell me how to calculate averge of 96 rows in the quey designer  not by hard coding them.
    Is there any formula for creating it through formula or through calculations .
    And also how to calculate the maximum value and minimum value of the entire 96 rows  which is picking from a Z table -ZDC_2100.
    Iam having time blocks of 96 for 24 hrs each of  15Min.

    Hi,
    You can achieve using a counter at baselevel and use exception aggregation at query level...
    Also check the below links might be useful:
    http://help.sap.com/saphelp_nw04/helpdata/en/75/21054da1392649948e5b94e4fc4bce/frameset.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/d2/e0173f5ff48443e10000000a114084/frameset.htm
    Hope this helps.......
    Rgs,
    I.Ravikanth

  • How to calculate average in result in BEx

    Hi Expert,
    I have 2 fields one is project and another # of days to finished project (I used formula to calculate the # of days from start to finished date. NOw in result need to calculate average of days took to finished all projects.
    I belive formula will be ( # of days / projects) but how we can apply in query. If anyone know please help out I really appericiate.

    Hi,
    Right click on your formula and go to properties, there you have the options as "Calculate Result as" and "calculate single value as" from the drop down box you can select option as "Average".
    Regards,
    Durgesh.

  • How to calculate Average value stock value - MC.B

    Hi All,
    When we execute T code MC.B  we get material analysis report . In it we have a column AVG VAL STOCK VALUE.
    Can some one explain how it is calculated. I see the formula
    The average stock value of the valuated stock is calculated using the formula:
             beginning stock value + n stock value at month´s end
                                    n + 1
    Can Some one explain how it is calculated and what 'N' stands for?
    Thanks,
    Vengal Rao.

    MC.B is inventory turnover.
    In the selection screen you enter how many periods to analyze.
    by default it is today 06/11 to 08/11
    n is the number of periods
    so you have a beginning stock of period 06/11
    + end stock of period 06/11
    + end stock of period 07/11
    + end stock of period 08/11 (which is todays stock)
    so the formula is:
    beginning stock value + 3 stock value at month´s end
    3 + 1

  • How to calculate Average of Keyfigure

    Hi Gurus,
    I have a requirement where I have to calculate average of key figure value for 1 material.
    I tried using 'Average' in exception Aggregation but it just sums up everything.
    Can anyone please explain?
    Thanks

    Hi
    1. Include the key figure you want to average into the columns; call it KF1
    2. Create a Formula; call it CTR1, and in the detail view put a 1. (This 1-value is not used except to avoid an error in the formula syntax checker.) On the Aggregation tab, choose Exception Aggregation: Counter for all Detailed Values, and for the Ref. Characteristic, choose the same characteristic as the lowest level characteristic in the initial view of the output. E.g. if you only have 0CALMONTH in the output, choose 0CALMONTH. When you run this, the total at the bottom of this column should be equal to the number of rows in that column. Note that we use Exception Aggregation here so that the total at the bottom is calculated before the output is generated and is available to other formulas in the query design; if we were to use the Calculation tab it would look the same to us in that the total would appear at the bottom, but the calculation would occur too late for us to use within the query.
    3. Create a second formula, call it AVG1. The formula will be:
    SUMGT KF1 / SUMGT CTR1
    SUMGT accesses the Overall Result value at the bottom of the KF1 and CTR1 columns. You can find the SUMGT function in the Data Functions folder - turn on technical names first; the description is Overall Result. You could instead use SUMRT; the difference is that SUMGT will use the filters applied in the filter block; SUMRT will ignore them.
    3. Run the query. You should see the Average in every cell in the Average column. You can use this formula as input to another formula, or just use ( SUMGT KF1 / SUMGT CTR1 ) within a formula to access the average value.
    Thanks

  • How to calculate average if some of measure values are 0

    Hi
    I created a webI report on top of a Bex query, I have a more than 10 different measure in WebI report column on which i need to calculate average.
    If I  use the Average function provided with in WebI report it is calculating average for the measures which are having 0  values too, but i need to calculate average on a column only for those values which are not 0
    Ex:  Measure Quantity has values in the report like
    100
    100
    0
    100
    100
    Average function is calculating as 400/5
    but I need 400/4, because one of the value is 0, so i need to avoid that count which is zero and should divide it by 4 but not 5.
    One way is to custom create measure for all measures and make a if else condition and divided by that custom measure, but is there any other procedure?

    i hope this can help
    =Average([myMeasure]) Where ([myMesyre] <> 0)
    good luck
    Amr
    before the 0 add <> not Equal too sign < and >
    Edited by: Amr Salem on Jan 19, 2011 9:29 AM
    Edited by: Amr Salem on Jan 19, 2011 9:30 AM

  • How to Calculate Overtime Using Negative Time Management

    Hi Experts,
    We are having PA,OM & PY in our project scope. We have just configured TM uptill workschedule.
    But how to calculate the overtime when we are using negative time management.
    We are having International Payroll Driver.
    Regards,
    Irfan

    Hi,
    Thanks for your prompt response.
    But if the overtime is based on Basic , HRA and other wage components.
    How the configuration of the wage type takes palce.
    Regards,
    Irfan

  • How to calculate Average No. Of Years

    Hi Experts,
    I want to show the data of 'Average years spent by employees in a position'.I ahve the following data : Position, Employee, Valid From and Valid to as Characteristics and no key figures. With this data, I need to show something like this :
    <u>Position</u> <u>AvgNo.OfYears</u>
    Position1 -          5
    Position2 -        3.5
    The no. of years is calculated by the formula variable using the valid from and To characterisitics for each employee.
    I can get the average using aggregation in the result line . But all the employee names appear along with each position.i.e, if there have been 100 employees till date who have completed Position1, all of them will be displayed. I don't want to show the employees but just the position and the Average no. of years.
    If i hide the employees, only the text is not displayed -but there will be 100 vacant lines shown against 1 position (i.e, the no of employees).
    I am taking all the data from a DSO. I cannot create a new inforobject either due to some restrictions. Kindly help.
    Regards,
    Rekha

    sorry i was away for several days...
    did you find a solution?  I had really the same issue in the past and had no issues with using multiple formula variables.  When you say "it doesn't work" what do you mean?
    In the past I have done this:
    Material Attribute - Numerator --> Formula var - Num
    Material Attribute - Denominator --> Formula var - Denom
    Misc Attribute - Anything Numeric --> Formula Var - X
    CKF --> (Num/Denom) *(X/X)
    without the (X/X) the results would only be accurate if the detail characteristic was displayed in the rows.  With X/X the calculation worked at any level.
    I did the same logic for different cubes and data types including Sales, Inventory, Production Control, etc

  • How to calculate Average time from a date field

    Hi All,
    I have a date type field in my table .
    I want to calculate average time for a given country in a select query. Date has to be exculded. Only time has to be taken into consideration.
    Kindly help me.
    Sample data
    india 25-JUN-09 08:12:45
    india 25-JUN-09 09:01:12

    Take which one you want.WITH dates AS
      (SELECT sysdate x FROM dual
        UNION
       SELECT sysdate + 1 +1/24 FROM dual
    SELECT TO_CHAR(to_date(AVG(to_number(TO_CHAR(to_date(TO_CHAR(x,'HH24:MI:SS'),'HH24:MI:SS'),'sssss'))),'sssss'),'hh24:mi:ss')
       FROM dates;
    WITH dates AS
      (SELECT sysdate x FROM dual
        UNION
       SELECT sysdate + 1 +1/24 FROM dual
    SELECT floor(24 * AVG(x- TRUNC(x)))
      || ':'
      || floor(mod(24 * AVG(x- TRUNC(x)),1) * 60)
      || ':'
      || floor(mod(mod(24 * AVG(x- TRUNC(x)),1) * 60,1) * 60)
       FROM dates;By
    Vamsi

  • How to calculate average value?

    Hi all,
    I'm using Lumira 1.15. I'm doing some practices with the sample dataset BestRunCorp... I want to calculate the average value of gross margin which is grouped by lines so that I can use a line chart to show the difference between the gross margin value and average value.
    How can I achieve this ?
    Best regards,
    Shuang

    It looks like it calculates the average based on the dimension
    See below:
    If you take the "Best run" Excel file, sort by country, calculate the average in Excel, it matches Lumira's 4,056 (for Argentina)
    I am not sure I follow your divide by 12 logic?

  • How to calculate Average

    Hi,
    I have a calc that is supposed to calculate the average but I dont know how to do it.
    Time prompt: enabled to take X number of months.
    $$: a certain amount of $$  corresponds to each month taken by the prompt
    Example:  8 months (Jan to Aug), $100 each =  800 / 8 = 100
    3 months (Jan to March), $100 each =  300 / 3 = 100
    The final amount (average) has to be posted to all the months of the next year.
    The issue is how to tell BPC the number by which the sum is going to be divided because it varies depending on the months taken.
    Thanx, i'll post my script here.
    I also have a prompt for the category (version) which may be Real, Budget, etc...
    *SELECT(%vapi%,"id","conceptos","vap='i'")
    *WHEN conceptos
    *IS %vapi%
    *WHEN metrica
    *IS hojas_r,metros_r,precio_r
    *WHEN tiempo
    *IS %tiempo_set%
    *WHEN versiones
    *IS Real_2011
    *FOR %anio%=2012
    *FOR %mes%=ene,feb,mar,abr,may,jun,jul,ago,sep,oct,nov,dic
    *REC(expression= %value%, tiempo=%anio%.%mes%,versiones="esperado_2012")
    *NEXT
    *NEXT
    *IS Real_2012
    *FOR %anio%=2013
    *FOR %mes%=ene,feb,mar,abr,may,jun,jul,ago,sep,oct,nov,dic
    *REC(expression= %value%, tiempo=%anio%.%mes%,versiones="esperado_2013")
    *NEXT
    *NEXT
    *ENDWHEN
    *ENDWHEN
    *ENDWHEN
    *ENDWHEN
    *COMMIT
    Thanx
    Velázquez

    Hi Karthik,
    Thanx for the reply, I changed the following:
    PROMPT(RADIOBUTTON,%MESES%,"seleccionar meses a promediar",1,{"1 mes"," 2 meses"," 3 meses"," 5 meses"},{"1","2","3","5"})
    TASK(Execute formulas,LOGICFILE,%APPPATH%..AdminApp%APP%TestAlldoraVentas2.lgf)
    TASK(Execute formulas,FORMULASCRIPT,"*FUNCTION VIGENCIA=%MESES%")
    (this one above is important)
    I know that Run_Stored_Procedure is not supposed to coexist with WHEN/ENDWHEN structures... however, I still posted it in my script logic, therefore I got this error:
    TOTAL STEPS  1
    1. Execute formulas:      Failed  in 1 sec.
    2. FX Restatement:        completed  in 1 sec.
    CHECKLCK= No
    MESES=5
    (Member Selection)
    TIEMPO: 2011.ENE,2011.FEB,2011.MAR
    Execute formulasError
    error running stored procedure PROMEDIO 5: Could not find stored procedure 'PROMEDIO'.
    Please help me out...
    I also tried adding %tiempo_set%  to the R_S_P but still doesnt work...
    Script:
    *SELECT(%vapi%,"id","conceptos","vap='i'")
    *SELECT(%vapc%,"id","conceptos","vap='c'")
    *SELECT(%vape%,"id","conceptos","vap='e'")
    *SELECT(%toner%,"id","consumibles","tipo='T'")
    *SELECT(%drum%,"id","consumibles","tipo='D'")
    *SELECT(%fusor%,"id","consumibles","tipo='F'")
    *SELECT(%otros%,"id","consumibles","tipo='O'")
    *XDIM_MEMBERSET conceptos=%vapi%,%vapc%,%vape%
    *XDIM_MEMBERSET consumibles=consumibles_dummy,%toner%,%fusor%,%drum%,%otros%
    *XDIM_MEMBERSET lob=servicios_out
    *XDIM_MEMBERSET metrica=precio_r,pieza_r,hojas_r,metros_r
    *XDIM_MEMBERSET moneda=usd,mxn
    *XDIM_MEMBERSET oi <> oi_dummy
    *XDIM_MEMBERSET vendedor = 01,02,03,04,05
    *RUN_STORED_PROCEDURE=promedio(VIGENCIA)
    *COMMIT
    *WHEN conceptos
    *IS %vapi%
    *WHEN metrica
    *IS hojas_r,metros_r,precio_r
    *WHEN tiempo
    *IS %tiempo_set%
    *WHEN versiones
    *IS Real_2011
    *FOR %anio%=2012
    *FOR %mes%=ene,feb,mar,abr,may,jun,jul,ago,sep,oct,nov,dic
    *REC(expression= %value% / %meses%, tiempo=%anio%.%mes%,versiones="esperado_2012")
    *NEXT
    *NEXT
    *IS Real_2012
    *FOR %anio%=2013
    *FOR %mes%=ene,feb,mar,abr,may,jun,jul,ago,sep,oct,nov,dic
    *REC(expression= %value%, tiempo=%anio%.%mes%,versiones="esperado_2013")
    *NEXT
    *NEXT
    *IS Real_2013
    *FOR %anio%=2014
    *FOR %mes%=ene,feb,mar,abr,may,jun,jul,ago,sep,oct,nov,dic
    *REC(expression= %value%, tiempo=%anio%.%mes%,versiones="esperado_2014")
    *NEXT
    *NEXT
    *ENDWHEN
    *ENDWHEN
    *ENDWHEN
    *ENDWHEN
    *COMMIT
    Thanx
    Velázquez

Maybe you are looking for