How to set if condition for formulas in excel? - excel

How can I make an if statement in excel that will returns 999 if the A3 cell has this information (Your order qualifies for FREE Shipping Choose this option at checkout. See detail) otherwise print the number(for example for this information "This seller has only 3 of these available. To see if more are available from another seller, go to the product detail page" I would like to print 3). I attached what I've done by now. I will appreciate any help.
=IF(A2="Your order qualifies for FREE Shipping Choose this option at checkout. See detail",999,TEXTJOIN("",TRUE,IFERROR(MID(A2,ROW(INDIRECT("1:"&LEN(A2))),1)*1,"")))

Related

Collate all entries from one table that don't exist in another in excel

I have the following formula in the 'Available Staff' sheet:
=LET(AvailabilityCalc,FILTER(AllStaffProjectAllocationTbl, IF(ISBLANK($I$11),1,(AllStaffProjectAllocationTbl[Role]=$I$11))*IF(ISBLANK($I$8),1,(AllStaffProjectAllocationTbl[Employee]=$I$8))*IF(ISBLANK($I$14),1,(AllStaffProjectAllocationTbl[Discipline]=$I$14))* (AllStaffProjectAllocationTbl[End Date]<$I$2)*(TRANSPOSE(MMULT(SEQUENCE(1,ROWS(AllStaffProjectAllocationTbl),1,0),TRANSPOSE(AllStaffProjectAllocationTbl[End Date]>TRANSPOSE(AllStaffProjectAllocationTbl[End Date]))*(AllStaffProjectAllocationTbl[Employee]=TRANSPOSE(AllStaffProjectAllocationTbl[Employee]))*(1)))-MMULT((TRANSPOSE(AllStaffProjectAllocationTbl[Employee])=AllStaffProjectAllocationTbl[Employee])+0,SEQUENCE(ROWS(AllStaffProjectAllocationTbl),1,1,0))+1=0)),IFERROR(SORT(INDEX(AvailabilityCalc,SEQUENCE(ROWS(AvailabilityCalc)),{1,4,5,9}),4),""))
that sits in A2 and pulls in all staff that are available after a specific date defined in I2. This unfortunately has an issue as it pulls the data from the staff that have been allocated to a project previously from a 'Staff Project Allocation' sheet and doesn't incorporate the staff from the 'Staff Details' sheet that are yet to be allocated to a project.
The 'Staff Project Allocation' sheet :
The 'Staff Details' sheet :
Someone kindly helped me with the above function and I'm not sure how to modify it to do what I want. Could it be simpler to keep the above as is and create a new set of data to the right of it say, that pulls in the entries from the 'Staff Details' sheet that don't appear in the data created by the formula and are available from the date specified - whilst also being a development role, which I can do by checking their discipline against another table? Or is there a way to modifiy the formula above to incoporate the data? Something I also need to incorporate in the above function, which I overlooked originally, is to exclude any staff member that has had their employment terminated as noted in the Employment Status columns, so any suggestions on how to incoporate this too would be greatly appreciated.
I'm also starting to wonder whether a VBA solution maywell be a better approach, thoughts?
Edit 1
Adjusted function based on the suggestions from Max below. This now includes the ability to filter based on the employment status.
=LET(
staff, AllStaffProjectAllocationTbl,
employee, AllStaffProjectAllocationTbl[Employee],
role, AllStaffProjectAllocationTbl[Role],
discipline, AllStaffProjectAllocationTbl[Discipline],
endDate, AllStaffProjectAllocationTbl[End Date],
employmentStatus, AllStaffProjectAllocationTbl[Employment Status],
rowCt, ROWS(AllStaffProjectAllocationTbl),
roleSelection, $I$11,
employeeSelection, $I$8,
disciplineSelection, $I$14,
availableFromDate, $I$2,
empStatusSelection,"Employment Terminated",
mmult_1, MMULT(SEQUENCE(1,rowCt,1,0),TRANSPOSE(endDate>TRANSPOSE(endDate))*(employee=TRANSPOSE(employee))*(1)),
mmult_2, MMULT((TRANSPOSE(employee)= employee)+0,SEQUENCE(rowCt,1,1,0)),
roleCondition, IF(ISBLANK(roleSelection),1,(role=roleSelection)),
employeeCondition, IF(ISBLANK(employeeSelection),1,( employee=employeeSelection)),
disciplineCondition, IF(ISBLANK(disciplineSelection),1,(discipline=disciplineSelection)),
empStatusCondition, NOT(employmentStatus=empStatusSelection),
AvailabilityCalc,FILTER(staff,roleCondition*employeeCondition*disciplineCondition*empStatusCondition*(endDate<availableFromDate)*(TRANSPOSE(mmult_1)-mmult_2+1=0)),
IFERROR(SORT(INDEX(AvailabilityCalc,SEQUENCE(ROWS(AvailabilityCalc)),{1,4,5,10}),4),"")
)
Edit 2
I now have two tables, one from the Staff Details sheet, showing all staff who are development staff and still employed, this can be seen on the left in the following image (note this all staff allocated to a project or not) and defined by =FILTER(FILTER(StaffDetailsTbl,(StaffDetailsTbl[Employment Status]<>"Employment Terminated")*(StaffDetailsTbl[Dev Role]="Yes")),{1,1,1,0,0,0,1,0,0}), and a separate table defined by the Let function above in edit 1, showing all staff allocated to a project that are available based on a specified date, see table on the right.
I'd now like to merge the table on the left into the table on the right whilst also removing any duplicate entries. Would the most logical first step to be to adjust the filter for the left table to exclude entries that are in the right table? Then look to merge the two in to the right table somehow? Or is it possible to take the Filter defining the left most table and work it directly in to the function defining the right table?
Edit 3
The following function now filters out the entries from the StaffDetailsTbl Table that don't exist in the AllStaffProjectAllocationTbl Table:
=FILTER(FILTER(StaffDetailsTbl,(StaffDetailsTbl[Employment Status]<>"Employment Terminated")*(StaffDetailsTbl[Dev Role]="Yes")*(IF(ISERROR(VLOOKUP(StaffDetailsTbl[Employee], AllStaffProjectAllocationTbl, 1, FALSE)),1,0 ))),{1,1,1,0,0,0,1,0,0})
Giving the resulting table on the left for staff not allocated to a project and those allocated to a project and who are available after a specified date on the right:
I now need to figure out how to merge the filter formula from the left table in to the Let function above, or alternatively, build another table from the two that supports all the roleSelection, employeeSelection, disciplineSelection and availableFromDate functionality. Any thoughts on the best way I can do this please?
The formula logic is complex enough that it's unlikely someone here would be able to invest the time required to work through this on their own. It means someone has to "reverse engineer" the meaning of every reference, like "what does $I$11 really represent".
While not technically an answer, I can provide some help on how to simplify the problem, and then document the logic for your future reference. This won't meet the technical definition of a "proper" StackOverflow answer, but it's too much to fit in a comment and still better than leaving you empty-handed.
Use LET to simplify
You already have it, so let's go further with it, so we can simplify the formula as much as possible. Here's one example of using LET to further break down the formula, and using alt-Enter to create non-breaking returns in the excel formula:
=LET(
staff, AllStaffProjectAllocationTbl,
emp, AllStaffProjectAllocationTbl[Employee],
role, AllStaffProjectAllocationTbl[Role],
disc, AllStaffProjectAllocationTbl[Discipline],
endDate, AllStaffProjectAllocationTbl[End Date],
rowCt, ROWS(AllStaffProjectAllocationTbl),
mmult_1, MMULT(SEQUENCE(1,rowCt,1,0),TRANSPOSE(endDate>TRANSPOSE(endDate))*(emp=TRANSPOSE(emp))*(1)),
mmult_2, MMULT((TRANSPOSE(emp)=emp)+0,SEQUENCE(rowCt,1,1,0)),
roleCondition, IF(ISBLANK($I$11),1,(role=$I$11)),
empCondition, IF(ISBLANK($I$8),1,(emp=$I$8)),
discCondition, IF(ISBLANK($I$14),1,(disc=$I$14)),
AvailabilityCalc,FILTER(staff,roleCondition*empCondition*discCondition*(endDate<$I$2)*(TRANSPOSE(mmult_1)-mmult_2+1=0)),
IFERROR(SORT(INDEX(AvailabilityCalc,SEQUENCE(ROWS(AvailabilityCalc)),{1,4,5,9}),4),"")
)
This is still a lot to take in, but it separates the complexity of how we found/calculated the inputs from the actual Filter and Result logic at the end. if it was my sheet I'd go further and break the formulas down even more, like giving $I$8 or "transpose(emp)=emp+0" a name as well. The more granular, the better.
Then Document your LET formula right in excel
On another sheet, create an Excel table that documents the LET parameters:
Name
Equates to
Which means
disc
AllStaffProjectAllocationTbl[Discipline]
Discipline Col of Staff Table
roleCondition
IF(ISBLANK($I$11),1,(role=$I$11))
Role from I11, or 1 if I11 is blank
xyz
$I$11
describe what I11 is
I put "xyz" in row 3, but the point is to give a name to each thing, if you are not using name manager.
Hope this helps, either to add clarity for you, or to get someone else started creating a full answer.

Advanced lookup formulas based on a combination of unique rules

I am creating an attendance tracking form for work and require someone with more advanced knowledge of excel. This is to track employee tardy's and unplanned absences (UPT). When employees get too many tardy's or UPT's it is called an "Occurrence", when the number of occurrences increase it will increase the "Action Level". I input new data every 2 weeks and then send out emails to notify employees and their managers of increased action levels due to these attendance issues, I want this spreadsheet to do some of the work for me since I am working with hundreds of employees and so the process can sometimes take multiple days to complete.
My objective is to populate the Employee overview cells with the correct details from the Attendance Details page. The challenging part is that there are three rules that dictate which dates I need to populate the Employee Overview with.
Rule 1: Four tardies (TAR) makes an occurrence.
Rule 2: One UPT makes an occurrence, but if there can be multiple UPT's that only make one occurrence as long as they are within 5 days of each other.
Rule 3: Tardies and UPT's disappear after 365 days.
The increase of occurrences will increase the action level (See table in Employee Overview Screenshot).
In my example screenshots, the details should produce the hardcoded Employee overview I made for Bob Smith. I am not expecting anyone to have all the answers, but please help me by suggesting tips or tools available for accomplishing what I require. Please ask any clarifying questions if you wish to help but don't understand what I am requiring.
Screenshot of Attendance Details
Screenshot of Employee Overview for Bob Smith (Hardcoded)
I propose :
break the task/evaluation
Each rule may generate a set of new cell/data/table. thus, work with 1 rule first.
Repeat for another rule.
Consolidate.
these are just my head thinking out loud... hope it helps in anyways.. (care to comment? :)
Rule 1 : =if(countif(<TarRange>,"TAR")>=4,1,0) OR =countif(<TarRange>,"TAR")/4
Rule 2 : make a new list of "UPT"& its date, work from there. arranged the data by date, and use =if((day(<NextEntryDate>-day(<previousEntryDate>))<=5,<currentEntrydate>,"")
Rule 3 : every date cell values can be extracted using year(),month() and day(). Also look in to days calculation in excel help. I see that you'll need an extra column (beside the Rule 2 list) to do a moving summation. An example of moving summation is in the column H & I inside this post :
it uses if(<Day1>=<Day2>,<Count>,<DontCount>) Syntax. it can be change to year1/year2 in your case.
IMHO. Do share with us if you are stuck/successful. (:

Search formula for best text match among two excel lists

I have a long list of products (+20,000 items) of surgical instruments. Sometimes I receive requests for different names of these products which is impossible to manually match in my list.
I was thinking of a formula to find or suggest the closest result of match for the common words in each cell.
I have created this formula:
=INDEX('Products'!G:G,MATCH((("*"&LEFT(A2,5),'Products'!G:G,0))
(where Products G:G refers to my long list.
it gave some results correctly but more than 80% of the result came back with false results.
please see the attached image to show you the result.
is there is a way I can get more accurate result?
or I was thinking of finding major category of each item such as:
Category 1: Scissors, Retractors, Knives, etc.
Category 2: Straight, Curved, Angeled, etc.
Category 3: Sharp, Blunt, etc.
Category 4: 10mm, 130mm, 24cm, etc. (size)
which is easy for me to do it.
then use the same formula but with referring to the common words..
something like:
=INDEX(Products!G:G,MATCH("*"&LEFT(E2,5)&"*"&F2&"*"&G2&"*",Products!G:G,0))
where E2, F2, G2 refers to the categories..
I tried but it gave false results as well.
I urge you in the strongest sense of the word to spend some time creating a good quality master table and then spinning off 1 table for each category.
make use of clean(), trim(), proper(), heck, if you need to copy the data in notepad++ and enable view all symbols then switch between ansi utf utf8 wtf omgwtf or any other encoding to ensure you dont have any hidden special characters than do it.
you have 4 categories, so that's 4 1 column tables. name them. no duplicates. no trash. no junk. sort your data. nice clean names/words/whatever you categorize by. if you absolutely must add an index or key column then go ahead but do yourself a favor and stop there. use a different table to deepen your relationships.
next step is to to create comboboxes. i'm not sure why but the combobox in excel is not the same combobox in the vba editor. you want the one in the editor. you can make a fancy user form or you can make a minimalist text box design. whatever you fancy. just make sure the combobox has a field for RowSource in the properties. for whatever reason i don't get that option if i am not in the vba editor when i create the box.
you're almost gauratneed to want drawmodal = false on every user form you make for these boxes
you probably really don't need more than 4 boxes but it depends what you're doing so that's up to you. name your combo boxes.
verify each box has: matchentry = 1-fmMatchEntryComplete
i recommend: style = 0 - fmStyleDropDownCombo
this will allow you to begin typing and autocomplete the first match and also let you select from a drop down list, starting with the the first match of the name you've typed.
you can set the number of elements in the list. default is 8. if you have a slow computer than i wouldn't push it much. if you have a best then give it a shot.
you can also change fonts for easier reading and a bunch of other format changes.
now the this is the most important part - RowSource will be one of those 4 tables
now that i've given instructions, let me explain why. some businesses don't have the best practices and i'm currently with one that's using an oracle erp solution for data management but the front end isn't used. data entry is done in excel and loaded into oracle using batches. lookups in oracle continue to be a psychological barrier for the ap/ar teams so i did exactly what i suggested here but took it a few steps farther.
i pulled the vendor master and i pulled teh customer master
i cleaned the data and compiles simple pure clean 1 column tables
then i created a form for the comboboxes
first came ap with vendor name
then vendor number
then vendor remittance location
our orderering facility number
selecting a vendor name populates the vendor number box with the possible vendor numbers. same for remittance location and ordering facility
i pulled a year's worth of transaction data and created a gl table. some vendors have only ever used 1 gl acount. some several. there's a % number next to each gl. that represents the value of transactions posted from that vendor to that gl for the last year.
next up a date picker and text boxes for invoice fields.
get it nice and tight on a form, set the tab stops, add a commit button and all of a sudden we have a front end excel platform that performs better than oracle - because people use
i haven't finished the ar side but it'll get done and i'll the angels will be rejoicing and singing my name for years to come.
1:1 matching with autofill and drop down functionality you can't beat it. that's what you get with my suggestion.
best of luck!

Sharepoint Lookup

I have been absolutely stymied by Sharepoint lookups and the complete lack of information anywhere that relates to my problem so one last stab at seeing if anyone has a clue if not I am going to find another job which doesnt involve the use of this very good but highly complicated system.
My problem is that I want to add a column in list 1 that looks up a column in list 2, all very easy you may think and the nice videos on you tube make it seem very easy. So imagine the frustration when I create the column choose the appropriate list from "get information from" drop down and then go to the "in this column" drop down to find the fields i want are missing. I have tried this many ways and could not resolve it. So I decided to start again and set up a brand new list 2 which contains just 4 columns each created manually one column is "just single line of text" called Financial year the other three are a "number" and called Population, Dwellings and Non Domestic. Now having done that I would expect to see thos 4 columns (Financial year, Population, Dwellings and Non Domestic) all appear in the "in this column" drop down when setting up the lookup. But no of course not bloody Sharepoint will only show: Title, Financial year, ID , Content Type, version, and Title (linked to item) none of which I am the slightest bit interested in. I want to look up Population, or Dwellings or Non Domestic. Why is this so easy to do in Excel but in Sharepoint it seems as if Bill Gates has decided he's in charge of what people lookup!! in a word its crap.
I should have added that the same happens whatever list I select to look up from.

Excel - replace a formula cell with its result automatically

I am trying to make a sheet to add to templates that I give to my students for homework assignments; some of them are cheating by sending each other the files and I would like to catch them.
I have made a formula cell that populates with the current OS and directory of the file. What I would like to do is have this become text after evaluation so that if another student opens the file it will not change (but the following cell will, and so on..) Here is the formula:
(Cell A1):
=INFO("osversion")&INFO("directory")
(Cell A2 and beyond):
=IF(A1=(INFO("osversion")&INFO("directory")),"",IF(LEN(A1)<2," ",INFO("osversion")&INFO("directory")))
Do you know if there is any way to have a formula cell be replaced by its value after execution without using VBA? (If I use VBA it asks if you want to enable macros on startup which kind of gives the game away...)
Thank you in advance for your help!
There is a workaround: Use Track Changes. If you are using Excel 2010, for example:
Go to the Review tab and in the Changes group click Share Workbook.
Click the checkbox for Allow changes by more than one user at the same time.
In the Review tab, select Track Changes|Highlight Changes.
You may wish to select All for the When option and Everyone for the Who option.
You can then choose to highlight changes on screen and/or list changes in a new sheet.
If you do that before you make your final changes to the file, you can confirm that nobody has Accepted Changes between the last time you saw the file and the time it is returned to you by checking that your last change is shown correctly.
That will then let you see all the people who have edited the file since you last edited it, and what changes they have made.
(EDIT)
As #Siddharth Rout pointed out in another answer, one can use technological means to make cheating on assignments more difficult but a sufficiently resourceful student can always find a way to circumvent such measures.
This predicament can be resolved by distinguishing two cases:
(a) learning opportunities where students can choose to learn (do the assignment and get feedback on their approach - not a mark) or not choose to learn, and
(b) evaluation processes where one can measure how much they have learned (e.g. by getting the students together under one roof).
In case (a) students are not being evaluated and so have no motivation to "cheat". In case (b), they are being evaluated but have no opportunity to cheat.
Do you know if there is any way to have a formula cell be replaced by its value after execution without using VBA?
The answer to your question is "No, it cannot be done"
Even if you considered VBA as an option, it's futile as this is a classic example of XY Problem.
No matter what you do, you cannot stop your students from cheating. Consider these few scenarios.
Scenario 1
Student A has 1.xlsx. Student B has 2.xlsx. After student A finishes his/her assignment, he/she create a copy of 1.xlsx. Let's call it Copy.xlsx. Now Student A gives Copy.xlsx to Student B. Student B opens Copy.xlsx and copies the answers into 2.xlsx. Once finished, Student B deletes Copy.xlsx and gives you 2.xlsx. So now tell me how will you know Student B cheated?
Scenario 2
Student B calls Student A on mobile. They both have their copies opened. Student A gives all the answers on the phone. How will you know Student B cheated?
Scenario 3
Student A and Student B open files in two laptops next to each other and finish the assignment. How would you know who cheated whose assignment?
Alternative?
Get all the students under one roof and then get them fill it up in front of you. There is no other way you can even guess whether someone cheated unless someone is fool enough to mention other students name in his/her template or copied the answers verbatim.
You could always put some text in a cell location that only you know about and make the text white. You could code your text for each student and lock only the contents of that one cell with a password.
That's what I would do...
You can give each of them a different problem (maybe the same problem with different data). You will detect cheating of any kind by just looking at the results.
Programming or IT is not always the solution, even to programming or IT problems.

Resources