Excel: formula to identify missing sku - excel

I have a list of 1500 sku. Currently we have an active inventory of 450 sku.
I am looking for an excel formula that will identify when the sku inputed is not an active sku of the 450.
I have tried various IF functions, but having a hard time breaking it down.
I have tried this:
=IF($B2=F1:F460, COUNTIF(PRODUCTION!$A$1:$AJ$45, $d2), "")
The first part of the equation is where we input the inventory. F1:f460 is a list of all the active sku. The second part of the code is where it goes to look for the code if it on the production sheet.
I need to know when we put a sku into the inventory if it is correct or not.

=isnumber(Match(SKUYouWantToTest,450SKURange,0))
The match returns a number if the SKU is in the list, and an error otherwise. The isnumber converts it to a TRUE if it exists, and a FALSE otherwise

=SUMPRODUCT(--(SkuToTest=F1:F460))>0
The logic behind this is explained here. If you want to show only skus that are not in your list, you can wrap it in an IF like so:
=IF(SUMPRODUCT(--(SkuToTest=F1:F460))>0,"","FALSE")

Related

Get string inbetween two different characters at nth position

I have a spreadsheet containing image files in a column as such. I need to grab the product sku in the file names.
enter image description here
Example: "Img_Brand_AA_2021_202020-RD-Mens-Pant-RED-720p_Studio_1849.png"
The product SKU in the above example is: "202020-RD"
I need a formula to grab that product SKU. I've tried the following formula but it only spits out "2020" and I can't get it to grab the SKU.
=MID(E2, FIND(CHAR(1),SUBSTITUTE(E2,"_",CHAR(1),4))+1, FIND(CHAR(1),SUBSTITUTE(E2,"-",CHAR(1),3)) - FIND(CHAR(1),SUBSTITUTE(E2,"-",CHAR(1),2))-1)
One thing to note is the Product SKU can be longer than 6 characters.
Thanks!
I've tried the following formula but it only spits out "2020" and I can't get it to grab the SKU.
=MID(E2, FIND(CHAR(1),SUBSTITUTE(E2,"_",CHAR(1),4))+1, FIND(CHAR(1),SUBSTITUTE(E2,"-",CHAR(1),3)) - FIND(CHAR(1),SUBSTITUTE(E2,"-",CHAR(1),2))-1)
Assuming no Excel version constraints as per tag listed in the question. You can try the following:
=TEXTAFTER(TEXTBEFORE(A1,"-",2),"_",-1)
Here is the output:

Index with double Match returns incorrect closest values

I have an planning exported to Excel which looks like the following (tab ' Data'):
Each production line has a number of people working on it. Now is my goal to show how many people are working on a line per minute. We plan per product group, and several product groups combined form waht a line has to do per minute.
To get the production per minute I created the following (tab 'Conversie'):
=INDEX(Data!$H$2:$H$157;MATCH($N$1&A4;Data!$B$2:$B$157&Data!$C$2:$C$157;1))
In the example it works correct. However, the formula doesn't seem to always return the correct "Artikelomschrijving"(H) every time. I get incorrect return values when I extend this formula to other product groups.
I read that the data needs to be sorted ascending cause I use match_type 1. When I do that I get the right returns for some product groups, but the given example suddenly returns incorrect values.
I can't sort both column C and A in ascending order for the formulas to always return correct items. Can you help me to get past this hurdle?
After a little bit of google translate work, if I'm understanding your question correctly, you need to find the "Item Description" (H) of the record where the "Line" (B) = the value in N1 and the time is between the start and end times.
This is an array formula, you have to confirm it with Ctrl+Shift+Enter
=INDEX(Data!$H$2:$H$157,MATCH(1,(Data!$B$2:$B$157=$N$1)*(Data!$C$2:$C$157<$A2)*(Data!$D$2:$D$157>=$A2),0))
OR with semicolon syntax:
=INDEX(Data!$H$2:$H$157;MATCH(1;(Data!$B$2:$B$157=$N$1)*(Data!$C$2:$C$157<$A2)*(Data!$D$2:$D$157>=$A2);0))
I found the solution, thank you for pointing me in the right direction Valon Miller. This is the formula I fixed it with:
=ALS.FOUT(INDEX(Data!$H$2:$H$154;MATCH(1;(Conversie!L$1=Data!$B$2:$B$154)*((Conversie!$A32>=Data!$C$2:$C$154)*(Conversie!$A32<=Data!$D$2:$D$154));0));"")

Understanding a lookup formula used to calculate balances based on transactions

Below I was given the following formula to lookup the last transaction in an account (there is a total of 4 accounts) and calculate its current balance based on the transaction of the current row (in this case row 1075). $E$2:$E1074 is the range for the varrying accounts. $F$2:$F1074 is the range of balances associated with each of those accounts. $C1075 is the current transaction we are looking at on row 1075. The error is included in the case that the account in column E does no match an other account in column E and therefore is a new account and the first transaction for that account. This code works.
=IFERROR(LOOKUP(2,1/($E$2:$E1074=$E1075),$F$2:$F1074)-$C1075,-$C1075)
I have experience with vlookup and hlookup but I don't understand the first two sections of this lookup function. specifically the 2 and the 1/($E$2:$E1074=$E1075). I'm not sure what these two values calculate and output to give the desired result. Thank you in advance for your help
Why 2 is for much the same reason as why a "big number" or "big text" (say zzz) can be useful in a MATCH function (that I tried to explain here). Here any number larger than 1 would serve since the objective is to look for what does not exist in order to make the search continue through to the last entry. Returning that last entry, rather than an error for "Not found" may not have been intended - but can be very useful.

Multiple excel formulas

Ok, so I am first using the following formula to get my account string:
=IF(H20>=400,"8"&RIGHT(S20,4),S20)
This turns my account number from a 78899 into a 88899. Unfortunately that account doesn't exist. The 78899 is a default number that needs to be changed to a 88000 or a 88010 depending on the description in another column of excel. How do I maintain the original formula (because that formula works to change account numbers that already in a 78010 format that gets changed to a 88010 format. I need the first formula to also be connected with a secondary formula to look up key words in a field, i.e. pizza, or airline to then change the 88899 to a 88000 or 88010.
It sounds like you need a nest if with an and statement, if I understand correctly......something like:
=IF(AND(S20=78899,I20="pizza"),88000,IF(AND(S20=78899,I20="airline"),88010,IF(H20>=400,"8"&RIGHT(S20,4),S20)))
You did not specify where "pizza" or "airline" might be so I used I20, but you could change to fit your needs.

Excel: How to parse/cast text as a formula?

Is it possible to parse/cast text (like "=A1+A2") as a formula in MS Excel? I want to build a formula from pieces of text - some of which will only be typed in later by a user.
If the INDIRECT() function did not only work for referencing cells, then I could have typed this =INDIRECT("=A1+A2").
I know you can a work around this problem by simply adding a lot more hidden columns to do sub calculations. But for the sake scalability and efficiency, I would rather do something like the above.
I found a similar questions here and here, yet they don't solve my problem.
The Real-world problem:
Read on for a better understanding as to why you would want to do the above
Scenario
Each item in the list consists of a string, which contains anywhere from 1 to 5 account names each. Each account name is followed by an account number in brackets. The length of the number determines the type of account. Part of the account number is a date, of which the date format depends on the type of account. Further more, each account type may have more that 1 account-number length associated with it, although each number-length[*] is only associated with 1 account type.
Objectives
Extract account-names and their respective account-numbers and account-types from a list.
Make an assumption as to the account-type from the account-number
Validate this assumption by inspecting the build of the number and elements in the name
Check the validity of the account-numbers depending on their type.
The tricky part (this is where my problem lies)
The account-types and their respective account-number-lengths are not known before hand, and are typed into a table by the user of the sheet, specifying a type of account and the number-lengths associated with this account-type. The user should type this into a list - not go and tinker around with delicate formulas
Done so far
Column A: Contains the raw data (each cell has up to 5 names and numbers)
Columns B..F: Each column extracts 1 name, remains empty if all are already extracted
Columns G..K: Each column extracts 1 number corresponding to its name in columns B..F, remains empty if all are already extracted
Columns L..P: Each column calculates the length of the corresponding number in columns
G..K
Now the user would type the following details into a table which assigns certain number-lengths an account type:
TYPE2, BUSINESS, (OR(length=13,length=6))
where length will later be replaced with the cell address which contains the calculated account number-length.
What I want to do now
Columns Q..U:
Should all indicate the account-type of the corresponding account-number in columns G..K. The idea is to build a nested if-elseIf-elseIf formula using the criteria typed in by the user as specified above. Example of one of the elseIF statements:
SUBSTITUTE(CONCATENATE("=IF(",criteria,",",type,",",errCode)),"length","O10"))
All of these elseIf statements will then be concatenated together to form a master formula which will then need to be parsed/cast as a formula to calculate the account-type
This proposal uses only 5 columns (1 for each account-number, containing the master formula) and a table specifying account-types and criteria, also keeping the user away from formulas. Editing 1 line of code (the criteria) will update all formulas. Efficient & Scalable.
Since the user should never tinker around with the formulas under the hood, a simple 1 column if-elseIf-elseIf is out of the question. The alternative to the above would be to make a separate column to test for each account-type for each account-number. Separating/Abstracting out each test to its own column results in much better readability, easier editing & much less debugging - Unless you like multi-screen-wide-formulas. Example: 5 account-numbers * 10 possible account types = 50 extra columns.
Each edit to any criteria needs to copied to 4 other non-adjacent columns and drag-filled down 10,000 rows (columns can not be adjacent since it is effectively a 5x5 array of columns). Not Efficient nor scalable. Unless I'm missing some elegant way of updating non-adjacent formulas in a single click
The rest of the validations error indications are trivial.
Sample data
Tshepo Trust (6901/2005) Marlene Mead (8602250646085)
Great Force Inv 67 Pty Ltd (200602258007)
Jane (870811) Livingstone (6901/2005) Janette Appel (8503250647056) James (900111)
I know all this would probably be much easier to achieve with clever usage of VBA, eliminating all the need to simulate abstraction, encapsulation, multi-dimensional arrays and functional programming on a spreadsheet. But until I can program in VBA, worksheet formulas will be my refuge.
[*]: account number-length could also be described as the amount of digits in the number or as indicated by this formula: LEN(accNumber)
In VBA you have access to Cell.Formula.
I usually used Range to peek a cell by address.
I'm not sure if this would answer your question(it's a very detailed question!), but if your user was entering the account numbers in a table (I'm calling it 'RefTable') , that was:
Length of account number | business type
----------------------------------------
6 | Accountant
8 | Advisor
Then you could just use a vlookup on the length of the account number, given you've already separated them out.
=vlookup(len(accNumber), Reftable, 2, false)
Make sure that you either use a dynamic range name, or specify plenty of space below in RefTable, so that when your users add types, they don't get lost.
Also, if you have two different accounts with the same length, this could get you into trouble.

Resources