Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Aggregated average

Hello:

I have the following question. If I have the following table:

    

city_iddatered_carstotal_cars
112/11/2015    10     50
112/12/2015     5     20
112/13/2015     0     10
212/11/2015     2     30

I would like to compute the average of red cars aggregated by the average by city.

For instance, {[(10 + 5 + 0)/(50 + 20 + 10)] + [(2/30)]} / 2

4 Replies
Not applicable
Author

Create a pivot table and add dimensions as your id,date and in the expression use avg(red_Cars)/total_cars

Thanks,

SV

eduardo_sommer
Partner - Specialist
Partner - Specialist

You can use the following expression in a text object, for example:

=sum(aggr(sum(red_cars)/sum(total_cars),city_id))/count(DISTINCT city_id)

Eduardo

jolivares
Specialist
Specialist

I don't understand very well your formula, but this expresion maybe help you see more clear:

Capture.PNG

Sum(Aggr(Sum(red_cars),city_id)) = Sum all values for each city

Sum(Aggr(Sum(red_cars),city_id))/Sum(Aggr(Sum(total_cars),city_id)) = Divide Red_Cars by Total_Cars

eduardo_sommer
Partner - Specialist
Partner - Specialist

If I understood the problem, the requirement was to obtain the average of the city of red_cars to total_cars ratio, and this is what my expression does

Look at the original expression

      {[(10 + 5 + 0)/(50 + 20 + 10)] + [(2/30)]} / 2 results in 0.12708333


My expression, also resulted in 0.12708333


Eduardo