Need help in excel formula - excel

1) I have two tables. 1st table contains data for more then 20,000 rows and 2nd table I already have the following columns details i.e. Region, Item, Number and I just have to get the Total value of the product from the 1st table
2) There are two types of prices in the 1st table . One is Retail Price and Another one is a Wholesale price
3) In each of the regions Rep, Item and Numbers are same in most of the cases, but the Total price is different
4) I am able to get the Total price details in 2nd table through vlookup formula (After concatinating the following columns i.e. Region, Item and Number from both the tables) wherever there is an account number for retail price
5) Currently I am manually updating "Total Price" details in 2nd table for Wholesale price which is taking lot of time.
Is it possible to build a formula to get the wholesale price details in the 2nd table, since there are more then one account number, but the price is same

If the wholesale price is the lowest price for the specific item, then you can find it with the formulas MIN and IF.
Based on your screen shot:
D is the column with the list of items
I5 is the cell with the item name for which you want to find the wholesale price
F is the column with the list of prices
If you enter the following formula in cell K5, it should find the lowest price for pencils
=MIN(IF(D:D=I5,F:F))
On this link, there is an explanation if you want to use multiple criteria.
http://www.contextures.com/excelminmaxfunction.html

try the sumifs function.
It takes multiple arguments and criteria. So it should look something like:
cell value at j5 = sumifs(f3:f23, b3:b23, h5, d3:d23, i5....)
you need to mark off which rows in your first table are wholesale selling. So it should be a column of some kind. Once you do that, let's say in column G, then you add onto the sumifs function...
, g3:g23, L5)
What you're doing is summing up all of the values in column F where h5 (region) matches in b3:b23, i5 (item) match in d3:d23, and where L5 (retail type) match in a new column g2:g23.
This will find all of the values that match that criteria exactly.
Vlookup is useful, but it's harder to scale IMO than the advanced if functions.

SUMIFS is probably the better way to go on this one, but as an alternative there is also SUMPRODUCT.
=SUMPRODUCT(($H3=$B$3:$B$20004)*($I3=$D$3:$D$20004)*($J3=$E$3:$E$20004)*($F$3:$F$20004))
The * acts as an AND statement in a logical check, and each of the ($H3=$B$3:$B$20004) is a logical check. When the row is true it will evaluate to 1. When it is false it will evaluate to 0. in the end you wind up with a list of prices or 0s that get summed. The end result is the sum of everything that matches your criteria.
The danger of using this formula is that it can get labour intensive as it is performing array calculations without being an array formula.

Related

Indexed percent rank in Excel

I have a percent rank below
=PERCENTRANK(INDEX(T$2:T$28557,MATCH($A408,$A$2:$A$28557,0)):INDEX(T$2:T$28557,MATCH($A408,$A$2:$A$28557,1)),T407,3)*100
I want it to return a ranking only for matching in column A. But it's returning a ranking for the whole data set. For example, I have a list of schools in column A and I want to find the percent ranking of students in each school, not the entire district. Is there a formula for that?
Here's some mock data. So I need to find out what the percent ranks in columns D and F are for each school independent of all the others.
Mock Data
As your data is sorted use COUNTIF() to get the end of the school name:
Put this in D2 and copy down:
=PERCENTRANK(INDEX(C$2:C$21,MATCH($A2,$A$2:$A$21,0)):INDEX(C$2:C$21,MATCH($A2,$A$2:$A$21,0)+COUNTIF($A$2:$A$21,$A2)-1),C2,3)*100
Put this in F2 and copy down
=PERCENTRANK(INDEX(E$2:E$21,MATCH($A2,$A$2:$A$21,0)):INDEX(E$2:E$21,MATCH($A2,$A$2:$A$21,0)+COUNTIF($A$2:$A$21,$A2)-1),E2,3)*100

Excel Ignoring If Statement During Index/Match/If/Large Command

I'm trying to create a chart that finds the name of the first (then second, third, fourth, etc.) largest entry (via total sales) that meet certain criteria from a second Excel worksheet. (i.e. I want to find the largest sales value that is of the good "Apples" and sold in "Europe" if you will, as well as display the customer that this largest sales dollar amount was sold to.)
I've created some code that is giving me the name corresponding to the largest value on the sheet (very good!). However, this name does not meet the criteria in my if statement.
Example code: =INDEX('Sheet1'!B:B,MATCH(1,INDEX(('Sheet1'!V:V=LARGE(IF(AND('2. Sheet1'!E2:E1000="Apple", 'Sheet1'!W2:W1000="Europe"), 'Sheet1'!V:V, ""), ROWS(C$1:C1)))*(COUNTIF(C$1:C1,'Sheet1'!B:B)=0),),0))
B is the column with the customer name, V is the column with the overall sales amount, E is the column showing the name of the item sold, W is the name of the geographic area, C is the column (on the new sheet) where the name of the customer will be duplicated.
What I want to see is the customer who bought the most apples in Europe...but instead I'm getting the largest sales volume over all.
To make it stranger, if "apples" and "Europe" don't appear on the top row of Sheet1, I'm getting #N/A. (This does not happen, though, if these are contained in the top row.)
Does anyone have any thoughts as to how to fix?
In the following sample data image, the formulas in AB2:AC2 are:
=AGGREGATE(14, 6, (V$2:V$21)/((W$2:W$21=AA2)*(E$2:E$21=Z2)), COUNTIFS(Z$2:Z2, Z2, AA$2:AA2, AA2))
=INDEX(B:B, AGGREGATE(15, 6, ROW($2:$21)/((E$2:E$21=Z2)*(W$2:W$21=AA2)*(V$2:V$21=AB2)), COUNTIFS(Z$2:Z2, Z2, AA$2:AA2, AA2, AB$2:AB2, AB2)))
If you need to do it all in one formula, substitute the formula from AB2 (sans =) for every occurrence of AB2 within the formula from AC2.
Fill down as necessary.

Formula for average entries per day

I have a very simple sheet with dates in column A and product names in column B. I just need to know how many sales I make on average per day.
Sales:
01/01/2018 PRODUCT A
01/01/2018 PRODUCT A
01/02/2018 PRODUCT A
01/02/2018 PRODUCT B
Average sales per day: 2
So I don't care what product it is. Just how many sales per day on average.
You can use counta(a2:a5) to get the count of items in a range (adjust your range to suit of course).
You can use the array formula sum(1/countif(a2:a5,a2:a5)) to get the count of unique items in a range. The way to get an array formula is to enter it with CTRLSHIFTENTER rather than just ENTER (it will show up in the formula bar with {braces}).
It should then be a simple matter of dividing the former by the latter to get the average items per unique item (sales per day and, again, this should be an array formula):
=counta(a2:a5)/sum(1/countif(a2:a5,a2:a5))
The only tricky bit there is the countif formula. The expression countif(range,value) will give you a count of all items in the range that match the value.
By making the value the same as the range, it counts (for each item in the range) the number of times an item appears.
So, if your range contains a,a,a,a,b,b,c, you'll get the array (4,4,4,4,2,2,1). Doing the sum of the reciprocals of those values for each cell in the range gives:
(1/4 + 1/4 + 1/4 + 1/4) + (1/2 + 1/2) + (1/1)
which is basically a sneaky way of counting the unique items.
Assuming dates are entered as real Date (and not just text that only looks like dates), use this
=COUNT(A:A)/SUM(--(FREQUENCY(A:A,A:A)>0))
(Frequency formula sourced from here )

Sum first five instances in Excel

I have an Excel table with three columns. Column A has a list of countries, Column B has a list of cities in each country and Column C has populations of those cities.
The way the table is structured makes it so that Column A will have repeated names of countries - as many times as the number of cities in each country, in column B.
I would like to sum the populations of the first five cities in each country.
I have tried using SUMIF and COUNTIF but haven't managed to do it. How can I sum the populations (in row C) of the first five cities appearing for each country?
Are you trying to sum the population of the first five cities in the list or the population of the top 5 most populous cities for each country (which if the list is sorted by population, these are the same)? If it's the latter you can do it with a one line array formula
=SUM(LARGE(IF(A:A="CountryName",C:C),{1,2,3,4,5}))
(Ctrl+Shift+Enter after setting up the formula)
Where you replace "CountryName" with a reference to the country you want the sum of the top 5 populations for. I think the only issue with this is it will fail if there are less than 5 cities in a country on the list.
Here is a version of the formula that works when there are less than 5 cities but still caps at out at the top 5. Getting an array of 1-n values is kind of an ugly hack in Excel but this seems to work.
=SUM(LARGE(IF(A:A="CountryName",C:C),ROW(OFFSET(A1,,,MIN(COUNTIF(A:A,"CountryName"),5)))))
(Ctrl+Shift+Enter after setting up the formula)
Add a column D. In D2 write the following formula D2=COUNTIF($A$1:$A2,$A2) and drag it down.
Now what this will do is ranking the instances of a particular country.
Now it's a very simple formula for column E, where you will get the sum
E2=SUMIFS($C$2:$C$1000,$A$2:$A$1000,$A2,$D$2:$D$1000,"<=5") and drag it down
Now for each country you will have the sum of population of first 5 cities

return the nearest number value above current cell within a list in Excel 2010

This is a little difficult to explain but I have a list of data, all in one column, that contains a department number and then below each department number is a long list of brands that correspond to that department number. So within this list there are multiple departments with brands listed underneath them.
My goal is to somehow return the value of the department next to each brand but because the department number is located above the list of brands and the data is changing each time I repull the report, the row numbers will not remain them same and there may be duplicate brand names, and I cannot figure out what formula to use because it is all contained in one column.
I need to come up with some type of formula that doesn't just search, but returns the value of the next number or value above the current cell and skips all of the text or blanks in between so it will grab the department number above it. Is there a way to do this or a better way to accomplish the goal of assigning each brand to the department above it while allowing for changing data each time I pull the report?
I tried replacing all of the text with 0's or blanks and then used the indirect function to say: =IF(BG24="",INDIRECT("BF" & ROW() - 1),""), but I assumed it would continue to loop and skip the zeroes or blanks until it found a number, but it did not, it just returned the zero value.
If I understand your problem correctly, the following formula should do it. Put it in cell B2. In cell A1, I'm assuming that there's the department number.
=IF(ISERROR(A1*1), IF(ISERROR(A2*1), B1, ""), A1)
This will work for a table like the following where no brands are numbers only:
1
Brand1
Brand2
2
Brand1
Brand2
To become:
1
Brand1 1
Brand2 1
2
Brand1 2
Brand2 2

Resources