Calculate Average from Groups - excel

I'm trying to take a table of web data (average % of page viewed) and create an average.
This is what my table looks like:
0-25% 954,353
26-50% 58,569
76-100% 73,653
51-75% 31,011
I'm looking to calculate in a cell that the average across all is XX %.

I guess this is what you are looking for:
Due to a lack of more information, we do not know what the actual distribution of the items in the range from 0 - 25% is. Hence, I am assuming that they all average out at 12,5% (the median). If you continue this line of thought then the overall average is nothing but an average of the medians or (looking at the formula) a SumProduct divided by the Sum of all items.

Related

Facing difficulty in Excel when creating a logic for moving average of different variables

So, the point is, in my dataset I have to create a variable "Moving Avg. Amt paid per sq. ft." and the formula or the logic I need is to calculate the last five values as per most recent transactions. i.e. most recent sales by date. but this average should only return value in case it matches the same building and same area variable.
This is what my data looks like
Area ID has three categories. Building number has 5 categories. Date is sorted in ascending order. Now my variable moving average should calculate last 5 averages w.r.t date but for the same building in the same area. e.g. there are buildings 1 and 2 in area 102. I need my Mov Avg. variable to calculate using conditions when it matches criteria of building 1 in 102 for past five sales and when it finds building 2 in the building number variable, it should calculate average of last 5 sales of that building in area 102.
So my approach to this issue was (which is flawed at the moment):
I calculate average of amount paid per sq. foot w.r.t area & building based on dates using the formula
=AVERAGEIFS($N$2:$N$6547,$D$2:$D$6547,D14,$C$2:$C$6547,C14,$B$2:$B$6547,B14)
but I cannot make this formula work, to calculate moving average whenever it meets the criteria. I tried the offset the point as well by 5 but the logic is not right and hence its not working and returning #value in the cells. The formula I used to offset the above condition is
=AVERAGEIFS((OFFSET(N13,5,,5)),$D$2:$D$6547,D13,$C$2:$C$6547,C13,$B$2:$B$6547,B13)
(These formulae are used in column Q of my data)
Need a support from the community as I am badly stuck in making this data useful and I am out of any ideas to make this work.
Edit 1: I am not sure how I can attach my excel file here so you may review the dataset. I have uploaded it on a third party site, for which the link is shared below, so you can view the file in detail.
https://file.io/hlciAHJOHzWA
Expected result is as I have mentioned the instruction said
"Create a variable called "mov. avg amt. paid per sq ft". For each row, this variable should calculate average amt paid per sq ft for the most recent past five sales (by date) for the same building in the same area."
And my approach to build a logic or formula to make this variable calculate moving average w.r.t date for same building in the same area doesn't seem to work because there might be some flaws.
In Office 365 you could use:
=LET(f,FILTER($N$1:N13,($B$1:B13=B14)*($C$1:C13=C14),""),
c,COUNTA(f),
s,SEQUENCE(5,,c-5),
IFERROR(IF(c<5,SUM(f)/c,SUM(INDEX(f,s))/5),""))
If there's less than 5 matches prior to the current sales it'll calculate the average of the count. If 5 or more matches it'll calculate the average of the last 5 prior to the current sale.

Allocation of shipments based on ranking (excel based solution)

I have got some list of shops. I have to allocate shipments based on their rankings. The allocation should happen in such a way that each shop should not get less than 25 shipments and more than 100 shipments. The actual question is explained below.
Total SHipments=150
Shop Id A B C D E
Allocation (%) 30% 28% 25% 10% 7%
Min. 25 25 25 25 25
Max. 100 100 100 100 100
Actual Allocation %*150
=45 42 37 15 11
My Requirement 45(>25) 42(>25) 37(>25) 25(<25) 1(<25)
So my requirement is based on the ranking, the excel should allocate actual allocation to the top rankers (Between 25 to 100) and as the ranking goes down, it should fulfil the need of better ranker and make it 25 and then allocate the rest.I think I have made the question clear but let me know if still ambiguity is there. I'm new to this community. Forgive me if I'm not able to post the question in proper way.
To get your required results based on the information in your table layed out in the manner in the screen shot below, use the following formula:
=INT(MIN(MAX($C$1*B$5,B$7),B$9))
The above formula is placed in Cell B16. The INT was used as your results for 37.5 was 37.
In cell C16 place the following formula and copy it to the right as required. This is based on the allocation being in descending order from left to right:
=IF(SUM($B$16:B$16)+INT(MIN(MAX($C$1*C$5,C$7),C$9))<=$C$1,INT(MIN(MAX($C$1*C$5,C$7),C$9)),$C$1-SUM($B$16:B$16))
The max function is used to return the minimum value. When your formula returns a result below the minimum value The max function returns the minimum value. The MIN function does the same when the result of the formula exceeds the maximum allowable value. It will return the maximum allowed value as it is the minimum of the two numbers.
UPDATE: Rank out of order
This does not work when their is a tie and total demand exceeds available shipments
I took your table and added a helper row to determine RANK Row 6. I used the following formula to come up with the rank
=RANK(B5,$B$5:$F$5)
With this method, it is possible to have ties. You can investigate how to come up with unique rank with ties. The rest of this solution will assume the there are no ties in rank.
In Row 11 the "demand" of each shop is calculated based on Max and Min constraints and is rounded down to the nearest integer. The following formula is placed in B11 and copied right:
=ROUNDDOWN((MAX(MIN(B5*$C$1,B9),B7)),0)
In row 13 the actually amount to ship or "supply" is determined with the following formula in B13 and copied to the right.
=IF(SUMPRODUCT(($B$6:$F$6<=B6)*$B$11:$F$11)<=$C$1,B11,MAX($C$1-SUMPRODUCT(($B$6:$F$6<=(B6-1))*$B$11:$F$11),0))
FYI - SUMPRODUCT performs array like calculations within it. As a result, avoid using full column/row references such as A:A and instead reduce the range to your data or something closer to it to avoid a lot of excess calculation which may bog down your system. This is particularly true when the formula is repeated in multiple cells.

Excel Finding average speed

I have got 1500 rows of travels. In column A I have got total time on travel, in column B total km driven. In column C I did calculation on the average speed of specific travel. Whats the best way to calculate the average speed of all travels? The lengths are from 0 to 20 kms approx, time always shorter than one hour.
First I eliminated all travels shorter than 2 km then
I managed to do a frequency table and have written frequencies of speeds in 0-5,5-10,... km/h. Now I can do a histogram, but should I eliminate more data or how to approach this problem?
In another cell enter:
=SUM(B:B)/SUM(A:A)
A common error would be to try to average the values in column C.
it depends on your data. if it is statistics, don't throw data away, use them.
you have column A for travel time, and column B for travle distance. using this two column you can find the total average speed like what Gary's student suggest i.e. SUM(B:B)/SUM(A:A).
you also have column C the average speed for each travel, you can use this two counter check. simply do SUMPRODUCT(A:A,C:C), you should find the result equals to SUM(B:B). if the results match, then i'll say "ok i'm satisfied with my calculation".

Calculating an average rate based on multiple columns

I'm trying to calculate an average fare rate per square metre. To do this, I want to calculate the total cost by multiplying the Quantity (col E), the Footprint (col Q) and the netcon objective per square metre (col AI) to get the total cost per line item, adding all these up, then dividing by the total footprint (E*Q) for the whole list (lines 4 to 503, most of which are generally blank).
Since I want to avoid any more helper columns, I'm hoping to find a one-cell solution. To that end, I tried building an array formula:
=($E$4:$E$503*$Q$4:$Q$503*$AI$4:$AI$503)/SUM($E$4:$E$503*$Q$4:$Q$503)
It gives a #VALUE! error, though, and since it's my first attempt at actually writing an array formula rather than just copy-pasting one I'm not sure where I'm going wrong.
Any ideas?
IF you are interested in avoiding an array formula this looks like a sumproduct operation. You could try this:
=sumproduct($E$4:$E$503,$Q$4:$Q$503,$AI$4:$AI$503)/sumproduct($E$4:$E$503,$Q$4:$Q$503)
and for your original formula, were you missing SUM at the start?
=sum($E$4:$E$503*$Q$4:$Q$503*$AI$4:$AI$503)/SUM($E$4:$E$503*$Q$4:$Q$503)

Excel 2010: Average results between 25th and 75th Percentile

I have managed to get a solution for an easy Average of the 25th and 75th percentile, but to average the values between them appear to be a tad problematic.
My current instruction is as follows:
{AVERAGE(AND(F$1:F$489>PERCENTILE(F$1:F$489,0.25),F$1:F$489<
PERCENTILE(F$1:F$489,0.75),F$1:F$489))}
I am trying to average all values in Column F where they reside between percentile 25 and 75.
Thanks!
In excel it helps to slip your formula into separate chunks. So in one column you print which percentile the values are in. Then you use that as input for the next. That way you can see what the intermediate values are.
For this you could actually use AVERAGEIF. This average you can give a condition that the percentile should be between 25 and 75.

Resources