Excel 2013: How to sum values of a given range by omitting values given in a different range - excel

I have a WorkSheet with ProfitCenter, Cities and Amounts (called Data).
Then I have a second worksheet (same workbook) with exceptions of cities (named Exceptions)
Now I would like so sum all Profitcenter amounts in a range on Data-Worksheet except those where there cities are in a range of the exceptions-worksheet, but just for a specified report.
E.g.:
Data-Sheet:
A B C
ProfitCenter | City | Amount
111 NY 1000
111 Paris 2000
222 Paris 3000
333 Rom 500
111 London 600
111 Helsinki 8000
Exception-Sheet
A B
City | Reportname
Paris A
Paris B
London A
To demonstrate a bit better what I want to do, here is the formula that doesn't work:
=sumproduct((Data!c:c)*(Data!A:A = "111")*(Data!B:B <> Exception!A:A)*(Exception!Reportname = "A"))
The Problem is, I have no fix cell value to use for comparison but two different ranges
Is there anybody who can help me solving that Problem?

The simplest approach here seems best for your purposes. This will be by adding in a helper column in your Data sheet, which will define each cell's acceptability for summation.
In your Data sheet, on column D, add this formula (starting D2 and copied down), which does the following things: (1) Counts the number of times that the city in cell B2 on the Data sheet appears on the exception list, (2) excluding items where the Report name does NOT equal "A" [you will likely want some method of formulizing which report you care about, but I left it hardcoded for now], and (3) Checks to see whether the amount of matches on the exception list is equal to 0.
=COUNTIFS('Exceptions Sheet'!A:A,B2,'Exceptions Sheet'!B:B,"<>A")=0
Then simply have E1 sum the results, as follows:
=SUMIFS(C:C,D:D,TRUE)

Related

How to use VLOOKUP function in MS Excel

I am very very new to Excel
I have two sheets
Sheet 1
Country PMU Cluster
A Asia Mercury
B Australia Venus
C North America Jupiter
All the countries and continents are unique here
In sheet 2
I have
CountryCode Country PMU Cluster
123 A
234 A
453 B
235 C
1 country can have multiple codes
I have to take the PMU and Cluster and merge it with Sheet 2 , sheet 2 will have an additional column of Country Code.
Any help is very much apprciated.
Replacing my answer per your edits.
I'm just doing this on a single sheet but you can easily adapt by pointing to your other sheet for your lookup array.
Here is the formula for cell G2:
==VLOOKUP($F2,$A:$C,2,FALSE)
Here is the formula for cell H2:
=VLOOKUP($F2,$A:$C,3,FALSE)
Drag your formulas down and you're done. Vlookup formulas are very useful I recommend looking up how they work as someone else could better explain than I. Basically, you are looking up a value (column F) in an array (columns A,B,C) and returning a column index (B = 2, C = 3, etc) for a match. Lastly, you are looking for an approximate (TRUE) or exact (FALSE) match. Almost always use FALSE.
Also, look up cell references and how to lock them (ie, how $ signs rules vary). That way you can easily drag formulas across and keep your lookup value and array the same.

Excel look up value in array, return next value

I would like to look up a value in a range and return the value in the next row, but can't quite figure out how to do this. I especially would like to do this with formulas rather than VBA, and preferably with built-in formulas than custom (VBA) formulas, due to macro security issues.
I'm using Excel 2010. My workbook has two worksheets, "assessment" and "lookup". In lookup, I have lookup tables.
"lookup" looks something like:
Column A Column B Column C
1 Sales Engineering Manufacturing
2 Alice Bobbie Charlie
3 Dawn Edgar Frank
4 George Holly Isabel
In "assessment," I have some some drop downs from which users select one name from each column in "lookup." Based on some other criteria, I then rank these and create a new, sorted list (using INDEX() and MATCH()) that produce the selected name and corresponding column name a new sort order
Column A Column B
10 Engineering Edgar
11 Sales Alice
What I'd like is to return the name from the next row.
Column C
10 Holly
11 Dawn
But I'm having real trouble figuring out how to get there.
Assuming lookups is located at B2:D5 (change as required) and the result data is at F2:H3 (change as required) enter this formula in cell H2 then copy down.
=INDEX(
INDEX($B$2:$D$5,0,MATCH($F2,$B$2:$D$2,0)),
1+MATCH($G2,
INDEX($B$2:$D$5,0,MATCH($F2,$B$2:$D$2,0)),0))

Automatically working out the average of filtered results

I have a spreadsheet where column P has a score between 1-6
The cell O4 has the following formula: =AVERAGEIFS(P8:P5000,P8:P5000,"<>6",P8:P5000,"<>0")
This formula searches for the average of the score in column P excluding 6, blanks and 0
Column O has staff names e.g John, Mark, Tim.......
What i want to do is for Cell O4 to automatically calculate the average of the figures shown in column P after i have used the filter function to show only results of a selected staff member.
I was hoping excel might be able to do this automatically however cell O4 appears to still be showing the average of the whole column P regardless of whether i have filtered or not.
I was given the formula below on another forum but it seems to be giving slightly wrong results albeit only by a small amount but i need to have the results exact if possible. Any help appreciated.
=SUMPRODUCT(1-ISNUMBER(MATCH(P8:P100,{0,6},0)),SUBTOTAL(9,OFFSET(P8,ROW(P8:P100)-ROW(P8),0,1)))/SUMPRODUCT(1-ISNUMBER(MATCH(P8:P100,{0,6},0)),SUBTOTAL(2,OFFSET(P8,ROW(P8:P100)-ROW(P8),0,1)))
Maybe
{=AVERAGE(IF((P8:P5000<>6)*(P8:P5000<>0)*SUBTOTAL(103,INDIRECT("O"&ROW(8:5000))),P8:P5000))}
will do what you want. Assuming the Filter is on column O.
The 103 in SUBTOTAL will also exclude if rows are manually hidden. If this ist unwanted and it should only exclude hidden rows, if filtered, then use 3 instead.
This is an array formula. Input it into the cell without the curly brackets and then press [Ctrl]+[Shift]+[Enter] to create the array formula.
I would create a separate table in a new sheet with all unique staff members and then perform the calculation. This way, you can quickly compare values for all staff just by scanning the table instead of having to constantly update the filter to see the values for potentially dozens or hundreds of staff. You would add the staff name range and criteria to your AVERAGEIFS formula.
For your example:
Sheet 2
A B
--- ---
1 | Staff Average
2 | Bob =AVERAGEIFS(Sheet1!$P$8:$P$5000,Sheet1!$O$8:$O$5000,A2,Sheet1!$P$8:$P$5000,"<>6",Sheet1!$P$8:$P$5000,"<>0")
3 | Mary =AVERAGEIFS(Sheet1!$P$8:$P$5000,Sheet1!$O$8:$O$5000,A3,Sheet1!$P$8:$P$5000,"<>6",Sheet1!$P$8:$P$5000,"<>0")
4 | Joe =AVERAGEIFS(Sheet1!$P$8:$P$5000,Sheet1!$O$8:$O$5000,A4,Sheet1!$P$8:$P$5000,"<>6",Sheet1!$P$8:$P$5000,"<>0")

Generating letter by its position in the alphabet

I want a formula that can return the letter of the excel alphabet (27 = AA etc.) of a given number.
The purpose of this is that I have a table that returns values in a spreadsheet. I am summarizing data of climate measurements in cities, this data takes up 4 columns (but the same rows and relative positions in each column, so I29 and J29 contain 2 numbers I need, and then M29 and N29 contain the same data for the next location.
I want to create a summary table that looks like the below
City Rainfall Average Sunshine Average
City A =I29 =J29
City B =M29 =N29
City C etc.
my problem is that i go up to a few hundred cities, and i want to be able to populate the cells automatically/fill down. I know what row the data is in but need to generate the column letters using the formula requested above, so I can use a concatenate to create the cell reference.
You can use the ADDRESS function.
For example, =ADDRESS(29,27) will return the string "$AA$29".
However, honestly in your situation I would use the OFFSET function, combined with ROW(). To illustrate, let's say your table starts with a header row on row 50 and data starts on row 51. The data for a given city would start (ROW() - 51) * 4 columns to the right of I29. So:
A B C
50 City Rainfall Average Sunshine Average
51 City A =OFFSET($I$29,0,(ROW()-51)*4) =OFFSET($I$29,0,(ROW()-51)*4+1)
52 City B =OFFSET($I$29,0,(ROW()-51)*4) =OFFSET($I$29,0,(ROW()-51)*4+1)
53 City C etc.
Of course, you have to be careful if you want to move these cells around; you'll have to change the 51.

Issues with VLOOKUP in Excel

I have a tax table in one sheet that has a list of tax values. For example:
Sheet1: Tax Tables
A B C
1 Min Max Taxed
-------------------
2 50 100 10
3 100 200 20
4 200 300 30
In another sheet I have a gross income value of say 120 in cell A1. What I want to do is have a vlookup (I'm assuming that's what I should use) that checks cell A1 to see if it's between the Min and Max and then outputs the taxed amount in B1.
Sheet2: Income
A B
1 Gross FedTax
-----------
2 120 Value from Column C goes here
I already have the sheet in Tax Tables set up with named spaces A:C=Min and B:C=Max
I tried doing this:
=AND(VLOOKUP(<A1,Min,3,False),VLOOKUP(>A1,Max,2,FALSE))
But not even close...
I just want to check column A in the first sheet to see if it's less than the the value in the second sheet, and check column B in the first sheet against the value in the second for if its more, then put the value in column C in the first sheet into the cell next to the value in the second sheet.
To use a VLOOKUP, put your maximums and minimums in the same column.
Then use the TRUE argument, which means it looks for the next value that matches. Assuming the value you're looking up in D2, you'd put a formula like this in E2:
=VLOOKUP(D2,$A$2:$B$5,2,TRUE)
First of all it is unclear what you would apply when the amount is exactly 50/100/200/300/... So i decided to include the lower limit in the interval and exclude the upper limit.
For this problem I would use a sumifs like this (you have to decide on which side to put the equal sign:
=SUMIFS(Sheet1!C:C;Sheet1!A:A;"<="&A1;Sheet1!B:B;">"&A1)
This would only take those elements in column C that have a value in column A smaller than or equal to 120 and a value in column B greater than 120

Resources