Dynamically Average in Cell (Excel 2016) - excel

I have problem with dynamically average calcuation.
...after adding (I change Average manually)
In my Excel file I have users with some values and I'm every month adding new values and there is also Average that must increase. Now I edit this manually but I want to do that automatically. Is it possible? How should be the formula for this?
Note that I cannot move cells.

First of all move the column with the average to a place where you don't need to move it anymore. Probably P column if you need to get all months in there.
Then in the P2 cell add this formula
=SUM(D2:O2)/COUNT(D2:O2)
This will first sum the range and then divide by the number of entries you have in the range.
However, this part: also Average that must increase is nothing that a formula can handle.
It will only calculate the average, sometimes it may increase and sometimes it will decrease.

As stated above, you should move the average calculation else where.
Another approach is to create a named ranges.
For John, we will use following formula for named range definition and call it JohnAvg, this is generic formula for dynamic range, it will expand for the defined line automatically, considering you have only the months data you want to average there:
=$D$2:INDEX($2:$2;COUNTA($2:$2))
Then, the formula for calculating John's average is:
=AVERAGE(JohnAvg)

=AVERAGE(OFFSET(F2,0,4-COLUMN(),1,COLUMN()-4))
(Written to start in cell F2)
This will use OFFSET to create a Range that starts in Column 4 (D) and extends until the Column before the Cell that the formula is written in.

Related

How do I create a formula that will return a date where the sum of it and previous dates are greater than some requested number?

Example of Product Data and Inbounds
I have 20 products that I sell that each have some requested amount that people want to buy. I am struggling to figure out a formula by which I could have it return the week where the sum of it and previous weeks is greater than the amount requested, so I know on what week of inbounds the order can be fulfilled.
The example data only shows three columns of dates but in reality there could be up to 20 weeks of inbounds inventory, so it would be potentially a large series of sums before it finds the one greater than the amount requested. In the example image the cells highlighted in green are the correct week for each product that I manually marked.
Thanks for the help, I'm not sure where to even start on this.
Assuming that your table start in cell A1 (therefore the cell C2 value is 96), use this formula for your conditional formatting starting from cell C2:
=AND(SUM($C2:C2)>=$B2,SUM($B2:B2)-$B2<$B2)
Warning: the formula might stop working if the overall structure of the table is changed. For example: if columns with non-numeric data are inserted, the user will need to re-apply the conditional formatting. If said inserted columns will contain numeric value that are not meant to be sum in the formula, it won't suffice anymore.
I am afraid I don't have time to write a full answer but the below might help. I am sure there is a way to avoid writing multiple COUNTIFS with a SUMPRODUCT but I haven't got there yet.
=SUM(1,
COUNTIFS($B3,">"&$C3),
COUNTIFS($B3,">" & SUM($C3:$D3)),
COUNTIFS($B3,">" & SUM($C3:$E3))
)
This is a model built around your having 20 weeks so that you can have one formula which doesn't require continuous adjustment - it does require one column of helper cells for each week, though:
the helper cells start in column Y, where the formula in Y2 is
=SUM($C2:C2)
which is then copied to the right as far as column AR, and then copied down, one row for each of your products.
With all of the helper cells populated, the array formula in W2 is
=IFNA(INDEX($C$1:$V$1,MATCH(1,N((Y2:AR2-B2)>0),0)),"In the future")
which is then copied down, one row for each of your products.

Google Sheets / Excel - Change value based on other cell

Quite a newbie when it comes to more advanced spreadsheet formulas. I am effectively trying to achieve the following on a finance spreadsheet.
I have multiple "accounts" with different values.
I have a sheet for money in and money out.
If account A has been selected in the previous cell, and then a value is added to either the money in or money out columns, I would like the value of the account to reduce or increase.
Hopefully this is enough info! Thanks.
You can use SUMIF. Take a look at this example:
By choosing the entire columns E and F, now whenever you add something below the transaction data, the balance will be automatically updated.
The arguments in SUMIF function are range, criteria and [sum_range] respectively. So in this one, we are summing the values of column F, where the corresponding value in column E is equal to A (which is placed in cell A2).
You can also use Excel Tables as a neater solution.
Use this formula in E3 and copy down.
=SUM(E2,C3,-D3)
E2, in this case, contains text (the column caption) which the SUM() function evaluates to 0. To this, the formula adds the amount in the Money In column and deducts whatever is in the Money Out column. One of these values will usually be zero but the total calculated by the formula will be the current balance.

Countifs for longer range

I am currently using Countifs to add up an amount of registrants that have a gender criteria and birth year criteria.
Formula:
=countifs(sheet1!N4:N90,”male”,sheet1!F4:F90,”1990”)
This works and shows me the amount of males born in 1990. I’m currently running this formula in sheet2. Every day or two I’ll import the registrations and the range will grow past row 90. Is there a way to write the formula that will adjust the result when I paste in new registrants?
Currently I can’t extend the formula past 90th row. And with all the birth years, it’s be great if I didn’t have to edit the formula manually every time I update the list.
There are at least 4 ways to do it:
Use "N:N" and "F:F" instead of "N4:N90" and "F4:F90". It will refers to the whole column.
Formula: =countifs(sheet1!N:N,”male”,sheet1!F:F,”1990”)
Use VBA (I'm not going to explain that now because I guess it's not what you want)
Use Dynamic Named Range like explained here https://www.excel-easy.com/examples/dynamic-named-range.html.
It applies to range without empty values (the height of the range is based on the number of values in the column and adding them to the row of the first row of your range (offset base).
We don't know how your registrant records on sheet1 look. I guess that on column A you have a record ID or something else that it's not empty until the table ends. While on column N and F you can have empty values (e.g. registrant year or gender is not mandatory).
So you have to create a named range 'Genders' that will refers to =OFFSET($N$1,0,0,COUNTA($A:$A),1) if you have not an header row. If you have one header row you have to start the offset from N2, etc. =OFFSET($N$2,0,0,COUNTA($A:$A),1).
You have to do the same thing for the birth year and use these named ranges in your formula, like:
Formula: =countifs(Genders,"male",BirthYears,"1990")
Convert the range of records to a table, selecting it and going to Insert-->Table. You'll be able to use table field names in the formula (Solution based on Ron Rosenfeld' comment)
=countifs(Table1[Gender],"male",Table1[BirthYear],"1990")

Excel - Find all identical cells, sum separate cell in row for matches, output in other sheet

So, I've searched for an answer to this, but I can't find anything. Hopefully some Excel guru out there has an easy answer.
CONTEXT
I have a sheet that has two columns; a list of airport codes (Col A) and a list of fuel gallons (Col B). Column A has a bunch of duplicate entries, column B is always different. It's basically a giant list of fill-up events for aircraft over time at different airports. The airports can be the same, because it's one row per fill-up event.
PROBLEM
What I want to do is have a formula that takes the enter data set, finds all identical entries in Col A, sums the Col B values for the matches, and spits out the result on a separate sheet with one entry for every set/match.
OTHER STUFF
I do not have a reference list for Column A and I would rather not create one since there are thousands of entries. I would like to just write a formula that does all this at once, using the data itself as the reference.
All the answers I find are "create a reference list on a separate sheet", and it's driving me crazy!
Thanks in advance for any help!
-rt
Sounds that you need a formula version of remove duplicated for column A, and a simple sumif for column B.
Column A
=IFERROR(INDEX(Data!A$1:A$1000,SMALL(IF(
MATCH(Data!A$1:A$1000,Data!A$1:A$1000,0)=ROW(Data!A$1:A$1000),ROW(Data!A$1:A$1000)),ROW())),"")
Array Formula so please press Ctrl + Shift + Enter to complete it. After that you might see a {} outside the formula.
Column B
=SUMIF(Data!A$1:A$1000,A2,Data!B$1:B$1000)
Just change the range for your data.
Reminders: The formula in columnA should starts from Row#1, or you have to add some offset constant for adjustments.
Since the returning value of MATCH() represents the position of the key in the given array. If we wanted it to be equal to its row number, we have to add some constant if the array is not started from ROW#1. So the adjustment of data in Range(B3:B1000) is below.
=IFERROR(INDEX('Event Data'!B$3:B$1000,SMALL(IF(
MATCH('Event Data'!B$3:B$1000,
'Event Data'!B$3:B$1000,0)+2=ROW('Event Data'!B$3:B$1000),
ROW('Event Data'!B$3:B$1000)),ROW())-2),"")
Further more, the range should exactly the same as the data range. If you need it larger than the data range for future expandability, an IFERROR() should added into the formula.
=IFERROR(INDEX('Event Data'!B$3:B$1000,SMALL(IFERROR(IF(MATCH(
'Event Data'!B$3:B$1000,'Event Data'!B$3:B$1000,0)+2
=ROW('Event Data'!B$3:B$1000),
ROW('Event Data'!B$3:B$1000)),FALSE),ROW())-2),"")
Lastly, I truly recommended that you should use the Remove Duplicated built in excel since the array formula is about O(n^2) of time complexity and memory usage also. And every time you entered any data in even other cells, it will automatically re-calculate all formulas once the calculation option in your excel is automatic. This will pull down the performance.

Updated Weekly Comparison between two values

I am trying to make an excel for keeping track of body weight.
On each SUNDAY, the new weight will be inputted by the user, this will go on for an infinite amount months. I want to be able to calculate the difference between last Sunday's input and the current Sunday's input when a new weight is inputted, then display the difference in a cell.
The problem is, I can do this for the first two inputs, but I want it so once you have 4 inputs, it will no longer use the 1st two weights for the calculation, but the 3rd and 4th, and same with 8 inputs, where it would use the 7th and 8th input for the calculation instead of 1st-6th and so on.
I have tried conditional formatting and if's, although it does not get the "use newest 2" effect I want. What could I use to do this?
Make sure you have a 'spare' column to the left of your weights. Let's take column A as the spare and then record your weights in column B. Allowing for column headings and generally laying things out nicely, let's say your first weight data is in cell B4, then the following week's data is in B5 and so on. In cell A4 enter the formula:
=A3+IF(B6=0,1,0)
Now copy this formula down for as many rows as you need in column A. Your formula to get the difference between the newest two weights is:
=VLOOKUP(2,A:B,2,FALSE)-VLOOKUP(1,A:B,2,FALSE)
[EDIT - allowing for 'calendar' view]
For you calendar view you are going to need a spare row above your weight data. You could hide this row if you wanted. Allowing for blank cells between your inputs I would use a slightly different technique. In this spare row (e.g. cell D2) put the formula:
=C2+IF(D3=0,0,1)
Copy this formula all the way to the right. The formula for your newest difference calculation now becomes:
=HLOOKUP(MAX(2:2),2:3,2,FALSE)-HLOOKUP(MAX(2:2)-1,2:3,2,FALSE)
If the entries will consistently be on a Sunday and on a weekly basis and you were happy to include the date in column A and your weight in column B then keep a rolling formula in column C:
In row 5: =b5-b4
In row 6: =b6-b5
This formula in column C can be dragged down using the small box in the bottom right of the cell and will automatically change the row number for you.

Resources