Sum column X based on value in column Y not being in array Z - excel

To keep things simple I have 3 columns (place holders used)
X - Contains Revenue
Y - Contains a number (hotel room number)
Z - Independent list of numbers (room numbers belonging to a certain category)
I'm trying to tally all the revenue in column X for rooms that do not appear in Column Z. Here is my attempt:
=SUMIFS(X2:X2000,Y2:Y2000,"<>"&Z2:Z198)
But that is still totaling all the revenue without the conditional. Pointers?

Try it with a SUMPRODUCT function.
As a standard formula,
=SUMPRODUCT(X2:X2000, --ISERROR(MATCH(Y2:Y2000, Z2:Z198, 0)))
Keep column X and column Y references limited to the actual data but the same size. Column Z should likewise be limited but does not necessarily have to be hte same size. Do not use full column references.

Related

Getting the max of a column based on criteria in another column

I have some data like:
Group
Alpha
Numeric (Sometimes)
1
A
Z
1
B
X
1
C
Y
2
B
Z
2
A
X
2
C
Y
A, B, and C repeat in that not necessarily in that pattern but always in groups together, while the numeric column is often numeric data that varies or text. How can I get the max numeric value for a group for just A and B using a repeatable formula (or a lambda function)? I have tried using vlookup for A and B in the range composing a group and passing the numeric column to MAX() but when the numeric column has text, MAX() and MIN() fail (even though it supposedly ignores text). Any ideas on how to get it to return correctly?

SUMIF but for products?

I have a table like the following:
X 1
X 3
X 2
Y 2
Y 5
Z 3
Z 4
I know I could use SUMIF to calculate the sum of the second column for each value in the first column, e.g., =SUMIF(A1:A7,"X",B1:B7) would give me the sum of values for X: 1+3+2=6. However, I want the product of values in the second column for each value in the first column. I.e., the output would be:
A 6
B 10
C 12
When I try to search for SUMIF but for product, I only see suggestions to use SUMPRODUCT, but that multiplies arrays together and then adds their values, whereas I don't want to sum anything, just multiply all the values within a column.
My only idea is to create a new column with the log of the values, then do EXP(SUMIF(...)) to get the product. However, this will not work if any values are 0 or negative. Is there any way to directly compute the product I want?
If one has the Dynamic Array formula FiLTER:
=PRODUCT(FILTER(B1:B7,A1:A7="X",0))
You can also use a Pivot Table:
There are probably cleverer* ways, but you could use this array formula:
=PRODUCT(IF($A$1:$A$7=D1,$B$1:$B$7))
*Edit - as I said, see Scott's answer. I always forget the new formulas.

Excel formulas to track sales - count and extract functions

This is an example of a sales tracking spreadsheet that I want to create.
I want column L to count the number of sales each person does but do it so that it runs in a fill series order. I have inputted data manually in column L to demonstrate.
there are approximately 11 different types of membership. As I enter the sales information in columns B to G, I want the types of membership in column G to extract to the breakdown box in columns P to T. This is so that I can see which staff member sells what types.
I want to replicate this formula to work out how much each staff member has taken financially. this would extract from H/I to the other box in column P to T.
Answer to the first part of your question:
I want column L to count the number of sales each person does but do it so that it runs in a fill series order.
Formula for cell L1
=COUNTIF($K$1:K1;K1)
For L2 it then becomes
=COUNTIF($K$1:K2;K2)

Excel: Count Only Once If Another Column Has Duplicates

I am trying to create a formula that will count the number of "Overdue" people instead of "Overdue" cells. Each person has the multiple rows with their name in it. The criteria to determine if it's "overdue" is:
-Column F and G are not within 3 years
-Column G are blank
-Column F = 0 and Column G are not within 3 years
The following code counts the criteria accurately. And doesn't account for duplicate names.
=SUM(COUNTIFS(TT[Fiscal Law 301 CBT],"<"&TODAY()-1065,TT[Fiscal Law 301 CBT],">"&TODAY()-1095,TT[Fiscal Law In-Residence],"<"&TODAY()-1065,TT[Fiscal Law In-Residence],">"&TODAY()-1095),COUNTIFS(TT[Fiscal Law In-Residence],"",TT[Fiscal Law 301 CBT],"<"&TODAY()-1065,TT[Fiscal Law 301 CBT],">"&TODAY()-1095))
The formula I want should count based on the criteria above and check column Z TT[Name] for duplicates and count them only once. And also count unique values once.
I just thought of another approach to this problem. What if I use the formula I have to create an Array, have another formula count the number of duplicates in Column Z from that Array, and subtract the two numbers.
This way should get me the correct number, i will still need assistance creating the second formula.
What you are after is a distinct count. Excel has a function for that in the new Dynamic Array function set, which is in Office 365 Insider builds but not available to everyone. Right now, a distinct count requires a few tricks.
For example, you can create a pivot table with the names in the rows, filter the table to include only values where column X = Overdue and use a CountA() on the result rows.
You are close, but not quite there.
Use a countifs formula like above. Then, create a column next to it with the logic if(countcell>0, 1, 0). This will return 1 if the person has at least 1 book overdue, and 0 otherwise. Then, take the sum of that column.
Formulas
I have provided a screenshots of the code that we would use (the E and F columns are dates). As you can see, the G column counts how many books are overdue. The H column provides a 1 if at least 1 book is overdue for each user. Then, we can simply sum the H column to find the total number of users with overdue books.
If this helps you, please consider choosing this as the answer.

Median Selling Price Excel Table

I have a spreadsheet with different products, listing units and retail value sold like the example below
Product Units Value
A 10 100
B 15 80
C 30 560
I'd like to compare the Average Selling Price with the Median Selling price, so I am looking for a quick formula to accurately calculate the median.
The median function requires the entire series, so for Product A above I would need 10 instances of 10 etc. How can I calculate the Median quickly considering the condensed form of my data?
Without writing your own VBA function to do this there are a couple of approaches that can be taken.
The first expands the data from its compressed frequency count format to generate the full set of observations. This can be done manually or formulaically. On the assumption the latter is required, it can be achieved using a few columns.
All the blue cells are formulae.
Column Eis simply the cumulative of column B and F is an adjusted version of this. Column H is just the values 1 to 55, the total number of observations given by cell L2. Column I uses the MATCH() with its final argument as 1 to match each observation in H against the adjusted cumulative in F. Column J uses the INDEX() function to generate the value of the observation. (Observations 1-10 have value 100, 11-25 have value 80 and 26-55 have value 560 in this example). The MEDIAN() function is used in cell M2 with column J as its argument.
This approach can be refined to take account of varying numbers of products and data points through the use of the OFFSET function to control the range arguments of the MATCH(), INDEX() and MEDIAN functions. And, of course, adjacent cells in columns I and J could be combined using a single formula - I've shown them separately for ease of explanation.
The second approach involves sorting the data by value (so in this case the data rows would become Product B in row 2, product A in row 3 and product C left as-is in row 4). It is then a case of identifying the middle observation number (if the number of observations is odd) or the middle pair of observation numbers (if the number of observations is even) and then determining the value(s) corresponding to this/these middle observation(s). In this approach the adjusted cumulative in column F is still used but rather than explicitly calculating the values in column I and J for every observation it can now be restricted to just the middle observation(s).
I think there is no way around compromises. Either using big amounts of helper cells or having the table sorted by the values.
Helper cells:
Formula in F4:AS6:
=IF(COLUMN()<COLUMN($F$4)+$B4,$C4,"end")
Formula in D2:
=MEDIAN(F4:AS6)
Sorted:
Formula in F4 downwards:
=SUM($B$3:B3)+1
Formula in D2:
=SUM(LOOKUP(INT(SUM(B4:B6)/2+{0.5,1}),F4:F6,C4:C6))/2

Resources