PowerPivot formula for row wise weighted average

Hi everybody,
I have a table in `PowerPivot` which contains the logged data of a traffic control camera mounted on a road. This table is filled the velocity and the number of vehicles that pass this camera during a specific time(e.g. 14:10 - 15:25). Now I want to know
that how can I get the average velocity of cars for an specific hour and list them in a separate table with 24 rows(hour 0 - 23) where the second column of each row is the weighted average velocity of that hour? A sample of my stat_table data is given below:
count    vel          hour  
133    96.00237    15  
117    91.45705    21  
81      81.90521    6  
2        84.29946    21  
4        77.7841      18  
1        140.8766    17  
2        56.14951    14  
6        71.72839    13  
4        64.14309    9  
1        60.949        17  
1        77.00728    21  
133    100.3956    6  
109    100.8567    15  
54      86.6369      9  
1        83.96901    17  
10      114.6556    21  
6        85.39127    18  
1        76.77993    15  
3        113.3561    2  
3        94.48055    2
In a separate `PowerPivot` table I have 24 rows and 2 columns(column1 is for hours and column 2 for weighted averages) and when I enter my formula, the whole rows get updated with the same number. My formula is:   
=sumX(FILTER(stat_table, stat_table[hour]=[hour]), stat_table[count] * stat_table[vel])/sumX(FILTER(stat_table, stat_table[hour]=[hour]), stat_table[count])
I have also asked this question at
Stackoverflow.

Hi Reza,
According to your description, you need to calculated the average value of Vel group on Count and Hour, right?
I have tested it on my local environment, the sample expression below is for you reference.
=CALCULATE(sum(Sample[Vel]),ALLEXCEPT(Sample,Sample[Count],Sample[Hour]))
If this is not what you want, please elaborate the issue, so that we can make further analysis.
Regards,
Charlie Liao
TechNet Community Support
Thank you,
Yes it works. But I decided to use a 'measure' rather than a calculated column. My measure's formula is:
=SUMX(stat_table, [vel] * [count]) / SUMX(stat_table, [count])

Similar Messages

  • I am a teacher and I want a formula for Numbers that will average out A, B, C, D and E's of my students.

    As the title says- I'm not much of a formula wizard and any help would be appreciated. Here's an example-
    Student A receives a B, C, A, A, D, A for 6 assignments. I want them to average out at the end of the row, as well as an average on a separate page of summaries for all subjects that are assessed this way.
    Ive seen it on an excel spreadsheet but was unable to look at the formula.
    Please help as the semester starts in a week for us in Australia!
    Thanks

    ellroy wrote:
    I basically want a formula where I can average Letters out to a B- or C+. Can I do this from just letters alone or do I need to assign numbers. Speaking to my curriculum coordinator, she said stick to LETTERS and see if we can sort out something for that as we don't officially report in numbers.
    So that would mean I would need an average formula that would calculate B + C + C + D + A into a single Letter. I dont know if it is possible without using numbers. I hope you understand what I'm trying to explain. It's quite hard!
    You say where the cutoffs are, is that A=90-100%?
    Can you just use letters to make an average of the letter? 
    AVERAGE, which calculates the arithmetic mean of a set of values, works with numerical values.
    On your posted layout, you have a table showing the letter equivalent of a percentage score:
    A score under 40 = E
    A score 40 or higher, but under 50 = D
    A score 50 or higher, but under 65 = C
    A score 56 or higher, but under 85 = B
    A score 85 or higher = A
    Those numerical scores may be summed, averaged, and a letter grade assigned. With the specifications given in that table, the letter grade will not include a + or -.
    Your layout includes nine numerical scores for the first student (all of which are well under 40. My assumption here is that each is the student's score out of the number in the same column of row 3 (ie, the first, 13, is 13 out of 14, the second is 10 out of 16, etc,)
    This raises a question:
    Does each point noted contribute equally to the final average?
    Or
    Does each quiz/exercise contribute equally to the final average?
    For the letter grades to be averaged, you will need to set a specific numerical equivalent (not a range) for each letter grade.
    For the letter grades and number grades to be combined into a single final letter grade, the numerical equivalents noted above must be chosen with that goal in mind, OR the numerical scores must be converted into letter grades, then reconverted into specific numerical equivalents for each letter grade, inserted into the set of (converted) letter grades, averaged, then reconverted to the equivalent letter grade.
    As you can see, there are yet a few hurdles to overcome.
    Regards,
    Barry

  • Regarding Logical level key and row wise initialization

    Hi Gurus,
    What is the purpose of row wise initialization in external table authentication and when we have to go for row wise initialization.
    Why we have to enable logical level key in hierarchy is this only for getting drill down to the next level if we make two columns as logical level key what will happens. If we want to enable a column as a logical level key what are the character sticks that column should satisfy.
    Thanks,

    1) Row Wise Initialization used to hold multiple values in a variable. Let says SQL gives 4 rows (A,B,C,D) as output. Now I want to hold 4 value in a variable to get this happen we need to go for RowwiseIniziation. If you do not do this at any point in time Variable holds only value A not others. Simply it works as Array.
    2) Level keys define the unique elements in each level and provide the context for drill down. You can make two logical columns as logical key but you need to make sure what to be displayed in your hierarchy by selecting DISPLAY. If you make to as separate logical keys and set Display for both you get two columns in the hierarchy
    http://gerardnico.com/wiki/dat/obiee/hierarchy_level_based

  • Row-wise Initialization: Use caching

    We have the 'Use Caching' check box available for row-wise initialized system variables. Although I do understand how this is useful as it shortens the login time for users who have logged in before by initializing the session variable from the cache instead of firing the query on the database everytime, I need to understand how this cache mechanism works especially when the overall server caching is disabled.
    I have faced a situation where the session variable was initialized from the cache although the server caching was disabled. Is there any way to purge this cache or set a refresh frequency? As of now I had to uncheck the 'Use Caching' check box to fetch the refreshed results in the session variable. But I believe this is undesirable in the long term.
    Thanks,
    Gaurav

    Had thought so. But then it means that you can use row-wise initialization with caching, only when the underlying data is never going to change. Restarting the BI server is not a viable option to clear the cache in systems which require 100% availability.
    But any ways, thanks for the input Dhar.
    Thanks,
    Gaurav

  • PLEASE HELP: PDF Forms, creating average formula for text?

    Hello,
    I really hope somone can help. I cannot find any answers to my questions on the internet, google etc.
    First time using Acrobat. Im pretty quick learning on compters however the formulas my boss has asked me to do I have no idea if they are possible.
    We have a report form for exams and each section I need to calculate the average mark for that section.
    There are 3 questions for the first section. There are dropdowns for distinction, Merit, Pass and Below pass to select for each questions.
    Please see picture attached to show you what I mean.
    I want to be able to calculate the most selected/average dropdowns selected and not count the N/A's into award1 field?
    The fields must be text and cannot be numbers.
    so for example, track 1 got a distinction, track 2 got a Merit, Track 3 got a distiction. all other fields left n/a
    is there anyway to do this also is there any way to exactly the same as above as check boxes? - please see picture attached
    I appriciate any help. I am working on a mac
    Thanks
    Lauren

    Thank you so much reply
    Yes on the dropdowns the distincion, merit, pass or below pass values are in the correct areas ready for selection. For example on the distiction row you can only drop down for distinction and so on for Merit row dropdowns etc
    Check box is the way I rather do it as its quicker, however I created the dropdown option just incase check boxes average was not possible
    On the check boxes if i select merit for rtack 1 I would just tick the box and leave the the rest of the colum blank with no ticks. So just by seeing the tick I know its in the merit section for Track 1. However I donts know if I can do an average formula for with check boxes.
    If I check boxed/slected distinction for track 1, distnction for track 2 and merit for track 3 (obvisley any box could be ticked depeneding how the exam went so need then all in the script). I would like it to then calculate the avergae mark which would be distinction in the award1 field. While the none ticked boxes or N/A fields not affecting the average.
    This is just the start to a huge form Im doing Im dreading the rest of formulas I have to do lol
    sorry if im confusing you

  • 11.1.2 FR Column formula not working for rows other than first

    Hi All,
    I've a FR Grid with following layout
    Columns: Budget, Forecast, Var(Var being a formula col with the formula COL[A]- COL)
    Rows: Children of Total_Cost_Centre, Children of Total_Projects, ACC.10101
    Suppress MISSING on for row
    When i run the report, the rows show the valid combinations having data but the VAR column shows value only for the first combination while for rest of the rows it shows 0.
    The row selection is in one row only, not separate rows so there is no specific setting that could create the difference in results.
    Any help would be greatly appreciated.
    Cheers,
    Abhishek

    Hi All,
    I've a FR Grid with following layout
    Columns: Budget, Forecast, Var(Var being a formula col with the formula COL[A]-COL)
    Rows: Children of Total_Cost_Centre, Children of Total_Projects, ACC.10101
    Suppress MISSING on for row
    When i run the report, the rows show the valid combinations having data but the VAR column shows value only for the first combination while for rest of the rows it shows 0.
    The row selection is in one row only, not separate rows so there is no specific setting that could create the difference in results.
    Any help would be greatly appreciated.
    Cheers,
    Abhishek

  • Constant Checking in Row Formula for Report Writer

    Dear All,
    Please advice what is the format to check a constant (string) in the row formula for Report Writer.
    Let's say if I want to check the cost center group -->
    If '&1KOSET' = 'ABC' then .... else......
    So, what is the format for ABC? Because if i put 'ABC' it will be treated as cell. But if i do not put the ' ', then i get system error.
    Thanks a million for your advice.
    Best Regards,
    CW

    Hi John Lee,
    The logic that you would want , can be implemented through a column set. That is, as per your logic written in the set, your column values differ.
    First in your set, keep your account number in the first set line. ie. 5000000.
    Then you enter the following formula in the second line of a set defined for a report column:
    IF u2018001u2019 > 5000000 THEN u2018001u2019 ELSE 0
    If the value in the first column (set line 001) is greater than 5000000, then this value displays in the second column; if the value in the first column is less than 1000, the value 0 displays in the second column.
    Revert if you need any additional help.
    Regards,
    Subin John

  • OBIEE 11.1.1.6.2 Row Wise Init for Roles variable

    Gurus,
    Why is the NQ_SESSION.ROLES ( Row Wise Initialized ) behaving differently when compared to other Row Wise initialized session variables.
    I am using EBS Authentication and Authorization for OBIEE, so my authorization query is
    SELECT DISTINCT 'ROLES', RESPONSIBILITY_KEY
    FROM FND_USER,FND_USER_RESP_GROUPS, FND_RESPONSIBILITY_VL
    WHERE FND_USER.user_id=FND_USER_RESP_GROUPS.user_id
    AND FND_USER_RESP_GROUPS.RESPONSIBILITY_ID = FND_RESPONSIBILITY_VL.RESPONSIBILITY_ID
    AND FND_USER_RESP_GROUPS.RESPONSIBILITY_APPLICATION_ID = FND_RESPONSIBILITY_VL.APPLICATION_ID
    AND FND_USER_RESP_GROUPS.START_DATE < SYSDATE
    AND (CASE WHEN FND_USER_RESP_GROUPS.END_DATE IS NULL THEN SYSDATE ELSE TO_DATE(FND_USER_RESP_GROUPS.end_Date) END) >= SYSDATE
    AND FND_USER.user_name = 'VALUEOF(NQ_SESSION.USER)';
    Now I plan to use these Roles( EBS Responsibility name) which I have populated in a DB table against some Cost Center and below is the how I view the data in DB.
    ID | PROFIT_CENTER | RESPONSIBILITY
    0 | 0 |0
    1 | 100 |BI_Fin_Role
    2 | 200 |BI_P2P_Role
    3 | 300 |BI_Inv_Role
    Then my Profit Centers Initialization Block is now
    SELECT DISTINCT 'PROFIT_CENTER', PROFIT_CENTER FROM WC_OBIEE_PC_SECURITY WHERE RESPONSIBILITY IN (VALUELISTOF(NQ_SESSION.ROLES))
    So User1 has BI_Fin_Role and PC_Security Role so does the User2 has BI_Inv_Role and PC_Security now when User1 logs in they should see only 100 Profit center data and User2 should see only 300.
    I have created data filter for that application role (PC_Security) and limiting with "Dim.Profit Center"."Profit Center" = VALUEOF(NQ_SESSION."PROFIT_CENTER")
    However first problem I encounter is there is no value definition for PROFIT_CENTER, snap that means the VALUELISTOF(NQ_SESSION.ROLES) value is not being passed or recognized by whenever BI Server sends that query to DB.
    This is confirmed by my query log which says:
    [2013-04-29T12:49:06.000+00:00] [OracleBIServerComponent] [TRACE:5] [USER-39] [] [ecid: 11d1def534ea1be0:48033065:13e4213bbd0:-8000-0000000000008dc8] [tid: 47796940] [requestid: fffe0313] [sessionid: fffe0000] [username: ] -------------------- An initialization block named 'PC_Security', on behalf of a Session Variable, issued the following SQL query: [[
    SELECT DISTINCT 'PROFIT_CENTER', PROFIT_CENTER FROM WC_OBIEE_PC_SECURITY WHERE RESPONSIBILITY IN (VALUELISTOF(NQ_SESSION.ROLES))
    Returned 0 rows. Query status: Successful Completion
    So I try to issue the SQL to BI Server thru Issue SQL Directly:
    SELECT "Profit Center"."Profit Center" FROM "SLA Details" WHERE "Profit Center"."Profit Center" = VALUEOF(NQ_SESSION.ROLES)
    and the query log gives be the below log which blew my mind as its being delimited by ';'
    select distinct T1260626.ACCOUNT_SEG3_CODE as c1
    from
    W_GL_ACCOUNT_D T1260626 /* Dim_W_GL_ACCOUNT_D */
    where ( T1260626.ACCOUNT_SEG3_CODE = 'BIAuthor;BIConsumer;PC_Security;BI_Fin_Role;AuthenticatedUser' )
    I have other Row Wise Init blocks for HR_ORG which when fired and used in reports give be stings ('1000','2000',...) which is what I was expecting to see in the filter and query here.
    Am I doing something wrong here can someone please point me to right direction please.
    Any help is much appreciated.
    Thanks,
    VidyaS
    Edited by: VidyaS on Apr 29, 2013 2:47 PM

    This is because the ROLES variable in OBIEE 11g is designed to retrieve the LDAP or DB groups etc.. in form of semicolon delimiters this would be not the same case with other Row Wise init blocks.
    Refer to : OBI 11g - LDAP and semicolon-delimited string for Groups [ID 1274964.1]
    HTH,
    SVS

  • Formula for cross tab row

    Post Author: bvandyck
    CA Forum: Formula
    The results of a row in a cross tab report need to be split out by percentages and added to the results of other rows.  Each row is an individual, except one row is a combination of individuals.  Certain individuals share in the results of the combination row.   The combination row will be zero after being added to the individuals' rows.  What is the formula for achieving this?

    Hi,
    U may create a new formula for that.
    There is an option in cross tab expert for new formula.
    U may create a formula of your choice and then insert in report.
    Regards,
    Misra P.

  • Formula for division of result rows in BEx 3.5

    Hi All,
    We have created 3 new formulas A,B and C respectively.C=sum/sum (At record level)
    Our requirement is that the result row of C should be calculated as "value in result row of A/value in result row of B".
    We are able to achieve this division for individual records but at the result row level this division does not work.
    Can someone please help us write a formula for this?
    Regards,
    Suchitra

    When you want to consider result of operands.
    C = SUMCT(A)/SUMCT(B)
    When you want to consider overall result
    C = SUMGT(A)/SUMGT(B)
    More on using these check the below link
    http://help.sap.com/saphelp_nw04/helpdata/en/03/17f13a2f160f28e10000000a114084/frameset.htm
    Hope this helps.

  • Formula for Average

    Post Author: kbrinton
    CA Forum: Formula
    Good Morning,
    I have a ticket number field that is a string so all I can do is a count on the field.  But I need to do an average.  Does anyone know a formula for this?

    Post Author: V361
    CA Forum: Formula
    What does the sting look like ?, is it just numbers, or numbers and characters 888-888-8888, depending on the string, you should be able to convert it to a number (using a formula) and then sum the formula.   Please provide an example of your strings if you can.

  • Different formulas for different rows in Formula Column

    Is it possible? If possible then how?

    Hi
    Yes in FR it is possible, you can apply a formula to entire columns, entire rows or specific individual cells. There is then a radio button that allows you to toggle between which formula is used (e.g. where a column formula and row formula intersect).
    I haven't used the new version of Planning yet to know about formulae in web forms I am afraid.
    Regards
    Stuart

  • Weighted Average in Pivot View

    Hi,
    Can you please throw some light on the below scenario based on weighted average:
    For Ex:
    Cloumn1---Column2-----Column3
    R1-----------Line Item1--10
    R1-----------Line Item2--20
    R2-----------Line Item3--30
    R2-----------Line Item4--40
    Now i am trying to achieve weighted average based on the group by of Column1.
    10+20=30==>30/2=15
    30+40=70==>70/2=35
    Before raising this thread, i had a look at the below URL:
    http://siebel.ittoolbox.com/groups/technical-functional/siebel-analytics-l/weighted-average-for-fact-column-values-1242947
    Can you please let me know how we can achieve this in the pivot view(OBIEE 10.1.3.4.1).
    Your help is highly appreciated.
    Thanks in Advance
    Siva

    Hi,
    Try-
    AVG(measure_col by column1)
    And try making in the column formula -Aggregation Rule (Totals Row)-->Average
    And also try making the aggregation rule in the pivot table of the column as-->Average
    Hope this helped/ answered.
    Regards
    MuRam
    Edited by: MuRam on Jun 11, 2012 4:46 AM

  • Use Session Variable with row-wise initialization

    Hello,
    I use an initialization block in order to load some translations in my repository (version is 11.1.1.6.BP1) :
    SQL :
    SELECT CODE_KEY, STRING_VALUE FROM "TABLES" WHERE  LANGUAGE_KEY= 'VALUEOF(NQ_SESSION.USERLOCALE)'
    Values :
    CN_INCOMING, Incoming, en
    CN_OUTGOING, Outgoing, en
    CN_INCOMING, Réception, fr
    CN_OUTGOING, Emission, fr
    etc ...
    I checked the row-wise intialization.
    The query is correct and returns the right values (I check in the log file ..).
    So far, So good.
    But when I want to use session variables in a column expression (in repository) like  :
    CASE WHEN "column"="xx" THEN VALUEOF(NQ_SESSION."CN_INCOMING")  ELSE VALUEOF(NQ_SESSION."CN_OUTGOING") END
    I got the error: [nQSError: 23006] The session variable, NQ_SESSION.CN_OUTGOING, has no value definition.
    If I used the same formula directly in Answers it's working correctly.
    Do I have to necessarily do this in answers or is there a way to do this in the repository.
    Thanks in advance
    Regards
    Benjamin

    Yes I already tested this point, when I don't use a row wise initialization it's working, but I don't want to create one variable for each translations that I need to use in column formula if you know what I mean.
    I don't understand why we can't use this kind of variable in this context ..but if I have to create the column in my analysis, I will do that, but it's not really user friendly
    Anyway thanks for your time.

  • Weighted average calculation in query

    Hello
    i'm having some issues calculating an weighted average...
    imagine the next scenario
    LINE | FORMAT | TIME | WORKERS
    10    | 000123    | 10   | 5
    10    | 000123    | 350  | 2
    10    | 000123    | 75   | 1
    From this i need the wighted average of the nr workers considering the time they were working
    so, to calculate that i have to do for example:
    (time * worker)/total time
    in numbers...
    ((105)+(3502)(75*1))/(10350+75)
    =1,89 workers for that line, for that format and for all that time
    I am able to do that formula inside bex analyser, however when the user drills down the report or sorts the key figures in other order the result is not correct.
    any suggestions?
    Best regards

    Hi Ricardo
    What we did, in a similar case, we used two formulas. The first one was the calculation (time * worker) with exception aggregation (summation).
    The second formula was the previous formula divided to time.
    The trick is which characteristic to use for the aggregation in the first formula, i think you should have the most detailed one.
    Then i believe the two formulas will calculate correctly the weighted average based on any selections/analysis that you do.
    Regards
    Yiannis

Maybe you are looking for

  • Are my movies in iTunes in the cloud

    Are my personal movies that are in iTunes in the cloud

  • Help with VS 2010 and 2012 (including the installer)

    Hello, I currently use VS 2012 Ultimate but I want to install the 2010 to create an installer. I wonder if it's going to clash the two VS studio. On the other, I want to ask that the support stopped and put installshield installer. I currently use th

  • Quicksliver or Launchbar and Photoshop/other Adobe CS Apps

    I'd like to hear how you use Launchbar or Quicksliver together with Ps or other CS applications. I've tried out QS over the last weeks and haven't decided what to with PS yet. For example you could have a Mouse/Pen gesture for New Layer or a Trigger

  • Time management &B payroll

    Hi Sap Gurus, Greetings for the day !!! i have just started my sap training classes from a location institute. hence kindly provide me the required material on Time Management & Payroll & the valuable Gudidance. Email ID : [email protected]

  • Partition exchange failure

    (Oracle 10g R1 on zLinux) I've got a large partitioned table with some partitions that are almost empty (but still claiming large amounts of blocks). To do some partition exchanging I created a second table that has exactly the same column layout (I