0

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 but 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])

reza
  • 90
  • 1
  • 14
  • It might help if you show a sampling of the data you are looking at. Then show us what you have tried. You've tagged both `excel-formula` and `powerpivot`. which would you like to use? – guitarthrower Apr 20 '15 at 15:53
  • From your question it is not clear what you want to achieve. Can you elaborate on it? Or give expected output? – Abhijeet Nagre May 28 '15 at 04:45

1 Answers1

0
  1. Create a new calculated column named "WeightedVelocity" as follows

    WeightedVelocity = [count]*[vel]
    
  2. Create a measure "WeightedAverage" as follows

    WeightedAverage = sum(stat_table[WeightedVelocity]) / sum(stat_table[count])
    
  3. Use measure "WeightedAverage" in VALUES area of pivot Table and use "hour" column in ROWS to get desired result.

Abhijeet Nagre
  • 876
  • 1
  • 11
  • 21