Sorting formulas issue - excel

I have a table which consists of names (1st column) avarageifs (2-6 columns) and average formulas (7 column).
Averageifs formula is taking the name to average values for each name:
=IFERROR(AVERAGEIFS(Grades!B:B,Grades!$A:$A,Rankings!$B14),"N/A")
"Total" average formula is:
=IFERROR(AVERAGE(C14:G14),0)
Then I am trying to sort it by "total" average, formulas are mixing up and referring to different rows.
But it should refer to the same row. What happens after sorting and how can I fix it?

Basically the references in the AVERAGEIFS formulae are getting swapped around and you don't want this to happen.
The easiest way round it would be to put the Totals column next to the Names column and just sort these two columns, leaving the other formulae in place.
If you don't want to do that, a fairly quick and dirty solution is to replace the AVERAGEIFS formulae with this so they always refer to the current row:-
=IFERROR(AVERAGEIFS(Grades!B:B,Grades!A:A,INDIRECT("Rankings!$B"&ROW())),"N/A")
See the discussion here

Related

Excel automatically sort column of numbers

I am looking to automatically sort a column of numbers in descending order without touching the sort button, or VBA.
Unfortunately I am trying to achieve this in a work environment where I have no access to VBA and excel is not one of the latest versions that contains the new SORT function in 365.
It is quite literally a column of numbers, and the numbers are automatically updated as they are totals of rows of smaller numbers elsewhere, and these change based on something else - so this specific column will always change numbers, but I need the column to automatically keep on top of sorting numbers by descending order.
I tried using rank.eq and some other bits with adding a 1 to each row to avoid duplicates, but this buggered it up if more than two duplicates was found. Is there anything I can do at all? Even if it involves going a very long way round it and building extra tables and things etc.
Grateful for any help.
It'd be easier to see your data and without being able to use a spill range, it's impossible to know how many rows. I also think you're intending to use LARGE function rather than RANK.
If you had your numbers in column A, you could drag the following formula down the appropriate number of rows to get the numbers sorted... (starting in cell B1)
=LARGE(A$1:INDEX(A:A,COUNTA(A:A),1),ROW())
If you can get your numbers in a table, you could use a similar formula but the table would ensure the appropriate rows exist (assume table name is Table1 and note the column names of RawNumbers and Sorted). Put this in Sorted Column:
=LARGE([RawNumbers],ROW()-ROW(Table1[[#Headers],[Sorted]]))
I presume using a pivot table is not a viable option... but these are how you could accomplish your objective of sorting by formula.

Calculate unique dates from multiple columns

I have three ranges of dates in Columns B7:B38, F7:F38 and K7:K38. Some dates are duplicates and some dates are unique. Some columns contains few values, and some columns are full. Which formula I can use to calculate unique dates value?
I find formula that work fine for one range, but can't figure out how to compare multiple ranges
=SUMPRODUCT(1/COUNTIF(B7:B38;B7:B38))
If I use COUNTIFS for multiple ranges
=SUMPRODUCT(1/COUNTIFS(B7:B38;B7:B38;F7:F38;F7:F38;K7:K38;K7:K38))
it calculate only one longest range of values.
Any advices? Thank you!
Hello Igor Oleksandrov,
I could not manage to do it in one formula but I think I have a solution for you: List the contents of your ranges with two passes of the small function. The Duplicates can be removed with some comparing in the middle.
In the first version of my answer I put the ranges in a name. That might be handy and nice, but luckily the small function can handle multiple ranges when in ().

Finding the sum of dates using first column value

So I am working in excel and have two columns, as shown below.
What I wish to do is to able to get the sum of yearly deadlines for A, B and C.
So that:
Get a sum of dates within Year 2020 for each Variable
Get a sum of dates within Month/Year for each specific A,B and C.
Currently, I have been using a long approach. I use a Vlookup for each row getting a filtered table for each Variable. Then using that I filter out Dates using combination of Countif and Countifs. But the problem with that approach is that I end up getting huge rows and table of data in the end increasing the file size.
I have also tried to use sumproduct() but I do not have numbers so I can not find a sum.
Is there a smart way of doing it using one formula?
Thank you.
Use SUMPRODUCT. For year/variable:
=SUMPRODUCT(($A$2:$A$13=E2)*(YEAR($B$2:$B$13)=$F$1))
for month/year/variable:
=SUMPRODUCT(($A$2:$A$13=$E2)*(YEAR($B$2:$B$13)=$F$1)*(MONTH($B$2:$B$13)=G$1))

Conditional Standard Deviation in Ms. Excel

So I want to count a standard deviation. I have two columns. The range of the first column is A2:A201. And this column have several labels, one of it is "Good" label. And the range of the second column is E2:E201, this column contains numerous values.
So how to count the standard deviation of the second column when the condition of the first column is "Good"?
And I thought this would work but it's not.
=STDEV.P(IF($A$2:$A$201="Good",$E$2:$E$201))
I suggest you calculating it with standard formula (Ctrl+shift+enter):
={SQRT(SUMSQ(B1:B4*(A1:A4="x"))/COUNTIFS(A1:A4;"x")-AVERAGEIFS(B1:B4;A1:A4;"x")^2)}
Another way is to add column with additional calculations.
Similar things work with sumproduct function for example (more information here: https://www.ablebits.com/office-addins-blog/2016/08/24/excel-sumproduct-function-formula-examples/)
Update: checked your formula in comment {=STDEV.P(IF(A1:A4="x";B1:B4))}, surprisingly it works))

Sum the product of multiple vlookup or index/match results

I have 2 worksheets, one with multiple columns of data where rows are given years and the other columns are values under the headers of names, and the second sheet lists rates by year (column) and by name (row).
I am trying to take each value in a given column of sheet1 and multiply it by the relevant rate (found by matching the year of each row and the name of its column to the table in sheet2) and then sum the products by name, but can only use a single cell to do all this.
So far I've tried SUMPRODUCT and got to =SUMPRODUCT(O$24:O$514,INDEX(Rates!$A$2:$X$200,MATCH(O$23,Rates!$A$2:$A$67,0),MATCH($D$24:$D$514,Rates!$A$2:$X$2,0))) but this seems to fall down at the MATCH($D$24:$D:$514,Rates!$A$2:$X$2,0) part, even entering as an array.
I've currently resorted to a clumsy series of SUMIF(2016)*INDEX/MATCH(2016 rate)+SUMIF(2015)*INDEX/MATCH(2015 rate) etc, but would really like to have forward compatibility without relying on formulae being updated!
slightly simplified image of the workbook, thanks for any help!

Resources