Airtable/Excel multiple if statement help (syntax seems the same) - excel

Just started up on Airtable and liking it already.
I'm looking to write some code so that if a cell in one column (e.g. October-19) is within September-November (which it is) the cell with the formula in will show 'Q1 Y2' (our quarters run September-August, don't ask why!).
The problem is I will have to do a huge nested if statement for every month, and then when we get to September-20 the formula will output 'Q1 Y3' and I'll have to run through the next 12 months. Any ideas?
IF({Completion Month}='October-19',"Q1-Y2",
IF({Completion Month}='November-20',"Q1-Y2",
IF({Completion Month}='December-20',"Q2-Y2", etc...
I've tagged this as excel as the if statement syntax seems to be the same.
Thanks,
Adam

Related

Excel Formula Slow

is there anything i can do to further improve performance of this formula ?
=IF($A3<>"",IF(Jan!$E6<>"",LET(d_patt,IF(Jan!$E6<>"",VLOOKUP(Jan!$E6,SETTINGS!$A$12:$B$27,2,FALSE)&IF(Jan!$B6<>"",Jan!$B6,0)&IF(Jan!$C6<>"",Jan!$C6,0)&IF(Jan!$D6<>"",Jan!$D6,0),""),"ROT"&IF(LEN(Teams!$BHR4)>0,MID(Teams!$BHR4,MOD(NETWORKDAYS.INTL(Teams!$C4,I$2,"0000000")-1,LEN(Teams!$BHR4)/3)*3+1,3),"000")&IF(LEFT(d_patt,3)="OVT",d_patt,"OVT000")&IF(LEFT(d_patt,3)="SSI",d_patt,"SSI000")&IF(LEFT(d_patt,3)="SSO",d_patt,"SSO000")&IF(LEFT(d_patt,3)="SDS",d_patt,"SDS000")&IF(LEFT(d_patt,3)="HOL",d_patt,"HOL000")&IF(LEFT(d_patt,3)="LID",d_patt,"LID000")&IF(LEFT(d_patt,3)="UNP",d_patt,"UNP000")&IF(LEFT(d_patt,3)="FLD",d_patt,"FLD000")&IF(LEFT(d_patt,3)="MAT",d_patt,"MAT000")&IF(LEFT(d_patt,3)="LIS",d_patt,"LIS000")&IF(LEFT(d_patt,3)="CBR",d_patt,"CBR000")&IF(LEFT(d_patt,3)="ABS",d_patt,"ABS000")),"ROT"&IF(LEN(Teams!$BHR4)>0,MID(Teams!$BHR4,MOD(NETWORKDAYS.INTL(Teams!$C4,I$2,"0000000")-1,LEN(Teams!$BHR4)/3)*3+1,3),"000")&"OVT000SSI000SSO000SDS000HOL000LID000UNP000FLD000MAT000LIS000CBR000ABS000"),"")
i have this on a sheet for each day of the year x 400 people so 146k+ times. this is therefor taken up 80% of the sheet load time.
The sheet basically gets shift patters from Teams, check if there is any holidays, overtime etc from the relevant month tab and relevant cell for the day, and then will generate a code like below.
ROT080OVT000SSI000SSO000SDS234HOL000LID000UNP000FLD000MAT000LIS000CBR000ABS000
i have so far managed to make this faster by using the LET function, but not show if its possible to make any further improvements.
if you need an example file i can send this or upload somewhere, not sure if that is possible via stackoverflow or a preferred site to upload to.
Thanks
The following is a shortened version of your formula to reduce the complexity of computations.
Instead of building the 'OVT000SSI000...' string one piece after another while always checking if the first 3 characters of 'd_patt' match the current piece, we can set the whole string with '000's as default and only replace the section that matches 'd_patt' (see highlighted elements in screenshot below)
Which results in the full formula:
=IF(LEN($A3)>0,"ROT"&IF(LEN(Teams!$BHR4)>0,MID(Teams!$BHR4,MOD(NETWORKDAYS.INTL(Teams!$C4,I$2,"0000000")-1,LEN(Teams!$BHR4)/3)*3+1,3),"000")&LET(default,"OVT000SSI000SSO000SDS000HOL000LID000UNP000FLD000MAT000LIS000CBR000ABS000",d_patt,VLOOKUP(Jan!$E6,SETTINGS!$A$12:$B$27,2,FALSE)&IF(LEN(Jan!$B6)>0,Jan!$B6,0)&IF(LEN(Jan!$C6)>0,Jan!$C6,0)&IF(LEN(Jan!$D6)>0,Jan!$D6,0),IF(LEN(d_patt)>0,REPLACE(default,SEARCH(LEFT(d_patt,3),default),6,d_patt),default)),“”)
If $B6, $C6 and $D6 can only be either empty or a numerical number, in other words, if they are never a letter or special character, the 'd_patt' function can be further shortened as follows:
Which results in the full formula:
=IF(LEN($A3)>0,"ROT"&IF(LEN(Teams!$BHR4)>0,MID(Teams!$BHR4,MOD(NETWORKDAYS.INTL(Teams!$C4,I$2,"0000000")-1,LEN(Teams!$BHR4)/3)*3+1,3),"000")&LET(default,"OVT000SSI000SSO000SDS000HOL000LID000UNP000FLD000MAT000LIS000CBR000ABS000",d_patt,VLOOKUP(Jan!$E6,SETTINGS!$A$12:$B$27,2,FALSE)&(Jan!$B6+0)&(Jan!$C6+0)&(Jan!$D6+0),IF(LEN(d_patt)>0,REPLACE(default,SEARCH(LEFT(d_patt,3),default),6,d_patt),default)),“”)

Problem with Excel IF function having too many arguements

I'm trying to automate a task for myself to see if I can see if an item is "overdue". However, I also wanted to add in a feature where if the item has been returned, then I won't be warned that that item is overdue. This is what I came up with so far:
=IF(OR(AND(A2<=TODAY()-14)), AND(D2=returned),"Overdue","Not due")
I'm currently trialling a 2 week loan period, where if the item is returned not returned within 14 days, I want the B column to show "overdue".
In my excel sheet, I'm currently trying to have cell B2 to show "not due" because while it has been more than 14 days, the item has been "returned" as can be seen from column D.
My current excel sheet
Thank you.
Try
=IF((OR(A2>TODAY(), D2="returned")), "Not Due", "Overdue")
Use the syntax for Example 2 to get a clean OR
Switch Not Due and Overdue because it is easier to reason about with OR than AND
Put quotes around "returned". Note you could use LOWER(D2) if you want to control for capitalization
=IF(AND(A2<=(TODAY()-14), D2<>"returned"),"Overdue","Not due")

Excel Formula overly complex

I have a formula that builds a string with If statements, CONCATENATE, and text formulas.
My problem is that the formula's getting extremely larger than I ever wanted it.
My formula first looks to see if a cell if blank
=IF(I3="","",Else)
The Second part is to check if the letters "DKB" is in the H cell
=IF(ISNUMBER(SEARCH("*DKB*",$H3)),True,False)
The Third is if the duration (Cell F) has 0 hrs do not include (HH)
=IF(TEXT(F3,"HH")<>"00",CONCATENATE(TEXT(F3,"hh\h\r mm\m\i\n"),CONCATENATE(TEXT(F3,"mm\m\i\n"))
The Fourth one is if the are 0 min don't include min selection
=IF(TEXT(F3,"MM")<>"00",CONCATENATE(Text(F3,"HH:MM")),CONCATENATE(Text(F3,"HH"))
If I were to write all the ways this could get played out I would have a total of 10 IF's. I want a simple way to write for each option without having to write out each answer. I have a partial code but doesn't include the minute portion. Is there a better way to do this? as you can see me using only if statements I'm not an expert.
Here's a picture to demonstrate my sample data and sample output
If we could have a variable for the first part ie:10-17 to 9:10 PM
2nd variable for duration
3rd variable for DKB
Would this be possible
Perhaps something like this is what you're looking for:
=IF(I3="","",TEXT(A3,"mm-dd-yyyy")&" On-Site "&TEXT(E3,"hh:mm AM/PM")& "- "&TEXT(G3,"hh:mm AM/PM")&" "&TEXT(F3,"hh\h\r mm\m\i\n")&IF(COUNTIF(H3,"*DKB*"),MID(H3,4,20),""))
=IF(I3="","",TEXT(A3,"mm-dd-yyyy")&" On-Site "&TEXT(E3,"hh:mm AM/PM")&"- "&TEXT(G3,"hh:mm AM/PM")&" "&IF(COUNTIF(F3,"*:00:*"),TEXT(F3,"hh\h\r"),IF(COUNTIF(F3,"00:*:*"),TEXT(F3,"mm\m\i\n"),TEXT(F3,"hh\h\r mm\m\i\n"))&IF(COUNTIF(H3,"*DKB*"),MID(H3,4,20),""))))
This Will Make is so It won't show 00hr or 00min

Automation of Subtotal range picking

For my internship I am trying to do an analysis of travel patterns in public transport.
Due to privacy reasons I cannot share the file, but I may describe the columns.
This is how it works.
I have a spreadsheet in Excel (2007) and it is called ReizigersData. That contains 15,000 rows of checkins.
The columns are: stopname, stopID, problemStop, D, E, productname, workday, saturday, sunday.
stopID can be seen as a primary key.
As you'll understand, the stops are repeated in several rows, because many different productgroups travel from the same stop.
Using a Advanced filter I have filtered out 3 relevant productgroups, reducing it to approx 300 rows.
The other sheet in the file is called ReizigersData (bundled).
In this sheet I want to get the subtotals per stop, combining the numbers of the three productgroups, although separated by workday/saturday/sunday.
This sheet contains the following columns: stopname, stopID, workday, saturday, sunday.
I have used the following codes:
In ReizigersData (bundled) stopname:
=INDEX(ReizigersData!$A$3:$A$14326;MATCH(B3;ReizigersData!$B$3:$B$14326;0))
In ReizigersData (bundled) stopID:
=SUBTOTAL(109;'ReizigersData (2)'!G174:G205)
These codes work.
The problem though is that I entered that range by hand.
Since it is a big database, I would like the subtotal formula to automatically determine which range he should pick according to the stopID in the bundled sheet.
I have experimented a bit and came up with this formula:
=SUBTOTAL(109;(INDIRECT("'ReizigersData (2)'!G" & Match(B3;'ReizigersData (2)'!$B$3:$B$14326))):(INDIRECT("'ReizigersData (2)'!G" & Match(B3;'ReizigersData (2)'!$B$3:$B$14326))))
Unfortunately this does not work; it returns 0. In Formula evaluator, it looks that the reference in the match part is the issue, because it refers to row 2297, which is not the one it should be.
Has anyone got any idea how to reach my goal?

Excel - How to combine these formulas into one?

I have this worksheet which lists results oldest to newest dates.
I have these three formulas..
=IFERROR(LARGE(IF([#HomeTeam]=[HomeTeam],IF("H"=[FTR],IF([Date]<[#Date],IF([#Season]=[Season],[Date],"")))),1),"NULL")
=IFERROR(LARGE(IF([#HomeTeam]=[AwayTeam],IF("A"=[FTR],IF([Date]<[#Date],IF([#Season]=[Season],[Date],"")))),1),"NULL")
=IF(AND([#[SLWD_H1]]="NULL",[#[SLWD_H2]]="NULL"),"NULL",MAX(Results[#[SLWD_H1]:[SLWD_H2]]))
Basically the first looks for the last time the home team won a game at home.
The second looks for the last time the home team won a game away from home.
And then the third gives me the latest date of the two mentioned above.
I was wondering if there was a way to combine all three into a single column instead of having to have three?
Thankyou in advance.
**EDIT
To make myself a bit clearer! What I want is to combine the above 3 into one formula which will output the result!
So it will find the date in example 1 and find the date in example 2 and then it will output the latest date.
Use the MAX formula to determine the highest date between the home and away dates.
The formula would look like this:
=MAX(Number1,Number2)
The MAX formula will ignore the NULL text values. However if both values are NULL, it will return a zero value. If formatted as a date it will show as 00/01/1900
=MAX(IFERROR(LARGE(IF([#HomeTeam]=[HomeTeam],IF("H"=[FTR],IF([Date]<[#Date],IF([#Season]=[Season],[Date],"")))),1),"NULL"),IFERROR(LARGE(IF([#HomeTeam]=[AwayTeam],IF("A"=[FTR],IF([Date]<[#Date],IF([#Season]=[Season],[Date],"")))),1),"NULL"))
If I understand correctly, would an OR("A"=[FTR],"H"=[FTR]) work? This would work like your first formula except using both "A" and "H" games.
=IFERROR(LARGE(IF([#HomeTeam]=[AwayTeam],IF(OR("A"=[FTR],"H"=[FTR]),IF([Date]<[#Date],IF([#Season]=[Season],[Date],"")))),1),"NULL")
Are these the only two values for [FTR]? If so you could just get rid of that IF statement entirely requiring either H or A:
=IFERROR(LARGE(IF([#HomeTeam]=[AwayTeam],IF([Date]<[#Date],IF([#Season]=[Season],[Date],""))),1),"NULL")

Resources