Trying to incorporate many conditions into one formula - excel

so I tried building the following massive formula:
=IF(AND(S284<>"",R284<>"",A284<>B284),INDEX(RATE, MATCH($A284,BID_NO,0), MATCH($R284,RATES,0)),IF(AND(S284<>"'',R284="",A284<>B284),INDEX(SHIFT_INFO, MATCH($A284,SHIFT_BID,0), MATCH(L$4,SHIFT_HEADER,0)),IF(AND(S284="",R284<>"",INDEX(SHIFT_INFO, MATCH($B284,SHIFT_BID,0), MATCH(L$4,SHIFT_HEADER,0)) <> INDEX(SHIFT_INFO, MATCH($A284,SHIFT_BID,0))),INDEX(RATE, MATCH($A284,BID_NO,0), MATCH($R284,RATES,0)),IF(AND(S284="",R284="",INDEX(SHIFT_INFO, MATCH($B284,SHIFT_BID,0), MATCH(L$4,SHIFT_HEADER,0)) <> INDEX(SHIFT_INFO, MATCH($A284,SHIFT_BID,0))),INDEX(SHIFT_INFO, MATCH($A284,SHIFT_BID,0), MATCH(L$4,SHIFT_HEADER,0))),"")
This formula was much simpler than this before but some conditions were added that we wanted to see if it could encompass them. It attempts to encompass several scenarios on a spreadsheet regarding schedule changes. Each schedule is assigned as a bid number in column A as well as one is column B. They are always equal until someone actually changes a schedule.
The purpose of the formula is to compare the data of the bid # in column A - The new bid they are going to and the data of the bid # in column B - the old bid that they are coming off of. In this case, this particular data is rate of pay.
If the rates of pay are the same, the formula will leave the cell blank.
If they are not the same, it will give the pay rate data of the new bid so we know what the rate needs to be changed to. As I mentioned, there were some added conditions in additional columns which I am now going to list:
**Bear in mind, There are 2 tabs giving different rates of pay since employees fall into Tier 1 or Tier 2 rates depending on when they were hired. Column "R" determines which tab a lookup will pull from. If "R" is blank, it pulls info from one tab of Rates which we will call Tier 1. If "R" is NOT blank, it pulls info from a different tab of rates which we will call Tier 2.
If column "A" is equal to column "B", then column "L" (this is the column that contains the big formula) is left blank. This condition takes precedence above all others.
If column "A" is NOT equal to column "B", column "R" is NOT blank, and column "S" IS blank, then do a lookup of the bid # in column "A" for that bid's rate of pay and do a lookup of column "B" for that bid's rate of pay. If the rate of pay for both Lookups match, column L is left blank. If they do NOT match, do a lookup for the number in Column A and display that rate. Because "R" has a value, the lookup will yield info from Tier 2 rates.
If column "A" is NOT equal to column "B", column "R" is NOT blank, and Column S is NOT blank, then do a lookup of the rate of the bid number in column A, even if the rate between A bid and B Bid are identical. Again, because "R" has a value, the lookup will yield info from Tier 2 rates.
If column "A" is NOT equal to column "B", column "R" IS blank, and Column S IS blank, then do a lookup of the number in column "A" for that bid's rate of pay and do a lookup of column "B" for that bid's rate of pay. If the rate of pay for both Lookups match, column "L" is left blank. If they do NOT match, do a lookup for the number in Column A and display that rate. Because "R" has NO value, the lookup will pull from the Tier 1 rates.
If column "A" is NOT equal to column "B", column "R" IS blank, and Column S is NOT blank, then do a lookup of the rate of the bid number in column A, even if the rate between A bid and B Bid are identical. Again, because "R" has NO value, the lookup will pull from the Tier 1 rates.
Again, I tried the formula at the top to encompass all of these scenarios. I got the 255 character limit message and so I am stuck. I realize this is way past information overload, so of course if it is easier and someone is willing to help, I can attach a template of the spreadsheet so that you can actually see what is being worked with. I can also be available for instant messaging to answer questions if that helps.

Related

How to change value of field based on values of two other fields in Excel or Google Sheets

I'm trying to create a customized personal expense report on Google sheets . If anyone has suggestions for a better approach, I'm open to to ideas!
In one column Category, I have option to select category with a drop down - Restaurants, Rent, Electricity etc. The column Value on the next to it holds the an integer value.
On a the same sheet, I have a column where all categories are defined. In the column Limit next to it, is the maximum integer value for each category. The next column Balance holds the remaining value (Limit - Sum of all Value matching Category)
My question is - when I add an entry in sheet 1 for any category with a value, how do I subtract the Value added from the respective Category to show the remaining balance from Limit in Balance column? As I keep adding items, the Balance field should get updated.
TABLE 1
Item Category Value
i1 Rest 100
i2 Rent 50
..
..
TABLE 2 (In same sheet somewhere adjacent to the above table)
Category Limit Balance
Rest 500 400
Rent 1000 950
..
..
Try using this:
=IFNA([limitcellname]-SUMIF([rangeofcategories],[categorycellname],[expensevaluerange]),[limitcellname])
Range of categories = column where all categories are listed in the expenses table. E.g- B:B if B column has expense categories
expense value range = column where all expenses are listed in the expenses table. E.g- C:C if expenses values are in C column
category cell name is the category cell in the balance table
limit cell name is the limit cell
This should work for your purposes

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.

Finding MIN Invoice Number Per Customer and Removing All Rows That Don't Match

I have an Excel file that shows online sales data. There are multiple columns, as you would expect, two of which are Customer ID and Invoice Number.
My aim is to only keep rows where the Invoice Number is the first (or MIN) Invoice Number for each Customer.
On a duplicate tab, we want the same thing, but only for the second Invoice Number per Customer (i.e. the second purchase).
On a side note, there can be multiple rows for the same Customer ID and same Invoice Number because the rows are at Item level, so it may look like this:
Row 1: Customer ID = 24; Invoice Number = 1014; Item = Jelly Beans
Row 2: Customer ID = 24; Invoice Number = 1014; Item = Candy Bars
So, that's okay. We just want to make sure any rows where the Customer's Invoice Number does not reflect their first purchase (or second purchase, in the second instance) is removed from the spreadsheet.
Is there a VBA (or even just functions) to achieve this? Even in steps: such as first highlighting those rows and then using another VBA to delete rows that are highlighted?
Again, in a nutshell I'm looking to only keep rows with the MIN(Invoice Number) per Customer ID.
Use COUNTIFS to count the number of times the customer number has appeared. Use a reference that is anchored to the first cell and changes as you drag down.
Assuming your customer numbers are in column A, insert this into B1 and copy down:
=COUNTIFS($A$1:A1,A1)
Filter on 1 or 2 accordingly.
Edit:
I didn't realise that you only wanted the first row. You can exploit the fact that MATCH will return the first result and check if it equals the row number:
=MATCH(A1,A:A,0)=ROW(A1)
Note that you may need to offset MATCH slightly if your data doesn't start from row 1. For example, if your data starts in row 3, you will need to offset your MATCH result by 2:
=MATCH(A1,A:A,0)+2=ROW(A1)
Now you can filter on the first column equalling 1 or 2 and the second column equalling TRUE.

Conditional Unique ID for each record excel

I have two values in different columns. Column A have Department name i.e. HR, Admin and Ops. and column be have date. I want Unique ID in column C based on Combination of Column A & B and Unique number at the end.
Unique ID: HR-Aug-16-1
Admin-Aug-16-1
this number will be repeat till the combination of Column A and B repeated 50 times after 50 times last value will be increased by +1. i.e.
HR-Aug-16-2
Admin-Aug-16-2
Right now I am using formula,
=A1&"-"&TEXT(B1,"mmm-yy")&"-1"
In C1 as a standard formula,
=A1&"-"&TEXT(B1,"mmm-yy")&CHAR(45)&INT((SUMPRODUCT(--(A$1:A1&TEXT(B$1:B1, "mmm-yy")=A1&TEXT(B1, "mmm-yy")))-1)/5)+1
I've set this to repeat after 5 for an example. I'll leave it to you to change the modifier to 50. Fill down as necessary.

Need help in excel formula

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.

Resources