Why am I getting the error - Too many arguments from this formula? - excel

I am trying to create a macro for the following formula. First though, I need to get the formula working when referencing a spreadsheet saved separately on the hard drive. Below is what I have but I am getting the error of Too many arguments.
=IFERROR(IF(C2<>"",IF(AND(VLOOKUP(A2&"",[LPSMatch.xlsx]Sheet1!$A:$B,2,FALSE)="Assigned Attorney",OR(B2="Jimmy Edwards",B2="Kathleen McCarthy")),"Sales Team",IF(AND(VLOOKUP(A2&"",[LPSMatch.xlsx]Sheet1!$A:$B,2,FALSE)="Intake Team, Assigned Attorney, or Sales Team",B2<>"Jimmy Edwards",B2<>"Kathleen McCarthy"),B2,IF(AND(VLOOKUP(A2&"",[LPSMatch.xlsx]Sheet1!$A:$B,2,FALSE)="Intake Team, Assigned Attorney, or Sales Team",OR(B2="Jimmy Edwards",B2="Kathleen McCarthy")),"Sales Team",IF(VLOOKUP(A2&"",[LPSMatch.xlsx]Sheet1!$A:$B,2,FALSE)="Assigned Attorney",B2,IF(AND(VLOOKUP(A2&"",[LPSMatch.xlsx]Sheet1!$A:$B,2,FALSE)="Sales Team",OR(B2="Jimmy Edwards",B2="Kathleen McCarthy")),"Sales Team",IF(C2<>"",VLOOKUP(A2&"",[LPSMatch.xlsx]Sheet1!$A:$B,2,FALSE),"INTAKE TEAM")))))), VLOOKUP(A2&"",[LPSMatch.xlsx]Sheet1!$A:$B,2,FALSE),"")
Any help? When I go to the function help all of the arguments are okay but it highlights the "" at the end of my formula.

fwiw, you can use Alt+Enter to add line feeds to your long formula and add a little legibility. The line feeds and 'white-space' do not negatively impact the formula's performance in any way.
    
All I had to do to get it working in its current state was at a ) to ... ,FALSE)), "") at the tail end.
There is some repeated logic that could be paired up. Line 2 could be OR paired with line 6 and 9 and line 11 seems completely redundant as you are still following the TRUE path for the first IF(C2<>"",... and the 'nothing matches' default appears to be doubled up. Here is my best shot.
=IFERROR(IF(C2<>"",
IF(AND(
OR(VLOOKUP(A2&"",[LPSMatch.xlsx]Sheet1!$A:$B, 2, FALSE)={"Assigned Attorney","Sales Team","Intake Team, Assigned Attorney, or Sales Team"}),
OR(B2={"Jimmy Edwards","Kathleen McCarthy"})), "Sales Team",
IF(AND(VLOOKUP(A2&"",[LPSMatch.xlsx]Sheet1!$A:$B,2,FALSE)="Intake Team, Assigned Attorney, or Sales Team",
OR(B2<>{"Jimmy Edwards","Kathleen McCarthy"})), B2,
IF(VLOOKUP(A2&"",[LPSMatch.xlsx]Sheet1!$A:$B,2,FALSE)="Assigned Attorney", B2,
VLOOKUP(A2&"",[LPSMatch.xlsx]Sheet1!$A:$B,2,FALSE)))), "INTAKE TEAM"), "")
An OR function (or AND function) can compare to an array of constants; e.g. =if(or("BCD" = {"abc", "bcd", "cde"}), ... would be TRUE. Using this method reduces the VLOOKUP functions significantly.
Footnote: the formula you are using is for an external workbook that is open. You would need full path(s) to the workbook if it is closed. If you get the formula working, close the external workbook and all of the full path(s) will be added.

Related

Excel formula to allow me to retrieve the codes of the most valuables drinks

Good night,
I'm trying to think of a simple excel formula to allow me to get the codes of the most valuables drinks.
I don't wanna use PivotTable for this one.
Ex:
I want to retrieve, for MALIBU, the code 8991
For JAMESON, the code 6113 etc
I'm stuck here since I woke up haha
Thanks!
Try below formula for dynamic spill result-
=LET(x,UNIQUE(C2:C12),y,BYROW(x,LAMBDA(r,INDEX(SORT(FILTER(A2:B12,C2:C12=r),2,-1),1,1))),HSTACK(x,y))
Using MAX function to consider the scenario where more than one code for a given drink can have the maximum value. In cell E2 use the following formula:
=LET(rng, A2:C13, codes, INDEX(rng,,1), values, INDEX(rng,,2),
drinks, INDEX(rng,,3), drinksUx, UNIQUE(drinks),
maxValues, BYROW(drinksUx, LAMBDA(ux,
TEXTJOIN(",",,FILTER(codes, (drinks = ux)
* (values = MAX(FILTER(values, drinks=ux))))))),
HSTACK(drinksUx, maxValues)
)
Here is the output:
Note: Another code for HEINEKEN was added for testing purpose of more than one code with maximum value.
XMATCH can be used for the same purpose too, but it is a more verbose formula:
=LET(rng, A2:C13, codes, INDEX(rng,,1), values, INDEX(rng,,2),
drinks, INDEX(rng,,3),drinksUx, UNIQUE(drinks),
maxValues, BYROW(drinksUx, LAMBDA(ux, TEXTJOIN(",",,
LET(maxValue, MAX(FILTER(values, drinks = ux)),
FILTER(codes, ISNUMBER(XMATCH(drinks & values, ux & maxValue))))))),
HSTACK(drinksUx, maxValues)
)

Nesting error in Excel Formula - Changes to If

I'm currently trying to record a macro for my excel spreadsheet, but keep recieving the message "The specified formula cannot be entered because it uses more levels of nesting than are allowed in the current file format can anyone help me out in fixing the formula to make it smaller?
=IF(ISNUMBER(SEARCH("Conductor + Surface",B3)),"Conductor + Surface",IF(OR(ISNUMBER(SEARCH("17
1/2",B3)),ISNUMBER(SEARCH("Drilling",B3)),ISNUMBER(SEARCH("12 1/4",B3)),ISNUMBER(SEARCH("8
1/2",B3)),ISNUMBER(SEARCH("Run Screens",B3)),ISNUMBER(SEARCH("Temporay",B3)),ISNUMBER(SEARCH("BOP
Hop",B3)),(ISNUMBER(SEARCH("Data Acquisition",B3)))),"Inter, Res, Lower Comp., &
TP&A",IF(ISNUMBER(SEARCH("Maintenance",B3)),"BOP Maintenance",IF(OR(ISNUMBER(SEARCH("Re-
entry",B3)),ISNUMBER(SEARCH("Wellbore Prep",B3)),ISNUMBER(SEARCH("Run
Completion",B3)),ISNUMBER(SEARCH("Install TH",B3)),ISNUMBER(SEARCH("BOP
Pull",B3)),ISNUMBER(SEARCH("Subsea Move Off",B3)),ISNUMBER(SEARCH("BOP Run -
Completion",B3))),"Upper Comp & TH",IF(ISNUMBER(SEARCH("Rig Move - N and C",B3)),"Rig Move - N and
C",IF(ISNUMBER(SEARCH("Install XMT",B3)),"Install XMT w/ Rig",IF(ISNUMBER(SEARCH("Open
Plugs",B3)),"Open Plugs",IF(ISNUMBER(SEARCH("Rig Move - S and B",B3)),"Rig Move - S and
B",IF(ISNUMBER(SEARCH("Install VXT",B3)),"Install VXT","ERROR IN EXCEL FORMULA")))))))))
Currently there is a column with tasks that are too in depth, aka "New Conductor + Surface" or "ADCO - DG2 8 1/2" I want to make a new column with shorter names for each of them depending on certain words that are in the detailed column. I would then like to return an error if there is a detailed task that is not described properly.
This can be done by modifying the setup in this link to a 2 column lookup table.
See below for sample:
Array formula is =IFERROR(INDEX(lookupList,MATCH(TRUE,ISNUMBER(SEARCH(list,D7)),0),2),"NOT FOUND")
remember to press Ctrl+Shift+Enter when exiting cell edit mode.

Excel CUBEVALUE & CUBESET count records greater than a number

I am writing a series of queries to my workbook's data model to retrieve the number of documents by Category_Name which are greater than a certain numbers of days old (e.g. >=650).
Currently this formula (entered in celll C3) returns the correct number for a single Days Old value (=3).
=CUBEVALUE("ThisWorkbookDataModel",
"[Measures].[Count of Docs]",
"[EDD_Report].[Category_Name].&["&$B2&"]",
"[EDD_Report_10-01-18].[Days Old].[34]")
How do I return the number of documents for Days Old values >=650?
The worksheet looks like:
A B C
1 Date PL Count of Docs
2 10/1/2018 ALD 3
3 ...
UPDATE: As suggested in #ama 's answer below, the expression in step B did not work.
However, I created a subset of the Days Old values using
=CUBESET("ThisWorkbookDataModel",
"{[EDD_Report_10-01-18].[Days Old].[all].[650]:[EDD_Report_10-01-18].[Days Old].[All].[3647]}")
The cell containing this cubeset is referenced as the third Member_expression of the original CUBEVALUE formula. The limitation is now that the values for the beginning and end must be members of the Days Old set.
This is limiting, in that, I was hoping for a more general test for >=650 and there is no way to guarantee that specific values of Days Old will be in the query.
First time I hear about CUBE, so you got me curious and I did some digging. Definitely not an expert, but here is what I found:
MDX language should allow you to provide value ranges in the form of {[Table].[Field].[All].[LowerBound]:[Table].[Field].[All].[UpperBound]}.
A. Get the total number of entries:
D3 =CUBEVALUE("ThisWorkbookDataModel",
"[Measures].[Count of Docs]",
"[EDD_Report].[Category_Name].&["&$B2&"]"),
"{[EDD_Report_10-01-18].[Days Old].[All]")
B. Get the number of entries less than 650:
E3 =CUBEVALUE("ThisWorkbookDataModel",
"[Measures].[Count of Docs]",
"[EDD_Report].[Category_Name].&["&$B2&"]"),
"{[EDD_Report_10-01-18].[Days Old].[All].[0]:[EDD_Report_10-01-18].[Days Old].[All].[649]}")
Note I found something about using .[All].[650].lag(1)} but I think for it to work properly your data might need to be sorted?
C. Substract
C3 =D3-E3
Alternatively, go for the quick and dirty:
=CUBEVALUE("ThisWorkbookDataModel",
"[Measures].[Count of Docs]",
"[EDD_Report].[Category_Name].&["&$B2&"]"),
"{[EDD_Report_10-01-18].[Days Old].[All].[650]:[EDD_Report_10-01-18].[Days Old].[All].[99999]}")
Hope this helps and do let me know, I am still curious!

Index Match to return MAX Date with multiple criteria

apologies for this, I'm assuming this is simple but a few hours of SO googling hasn't helped
Enough whining from me:
Consider the following dataset:
ID, Date, Review, Review Status
1 01/02/18, "Cool", Positive
1 01/03/18, "Awesome", " Positive
1 01/01/18, "Cumbersome", Negative
1 01/02/18, "Rubbish!", " Negative
I'm currently using an array type index match to get the latest review based on a few conditions
I have two columns one which says positive, one negative.
in each of the column I would like to return the latest positive review but I'm unsure how to get the max date within the below formula:
{=index(C2:C4, MATCH(1,(1 = A2:A4)*("Positive" = D2:D4)*(maxdatehere = B2:B4),0))}
The data I have is around 7k rows and is Google Review Data and pretty much matches the example above.
I'd rather not use VBA as I've never really used it before (but will do so grudgingly)
as this is excel I've not created a google demo sheet, but happy to do so for ease of the experts and for others to benfit if they find there way here one day.
If you have Office 365:
=INDEX(C2:C5, MATCH(1,(1 = A2:A5)*("Positive" = D2:D5)*(MAXIFS(B:B,A:A,1,D:D,"Positive") = B2:B5),0))
Confirme with Ctrl-Shift-enter instead of Enter when exiting edit mode.
If you have 2010 or later then:
=INDEX(C:C,AGGREGATE(15,7,ROW(C2:C5)/((A2:A5=1)*(D2:D5="Positive")*(AGGREGATE(14,7,B2:B5/((A2:A5=1)*(D2:D5="Positive")),1)=B2:B5)),1))
Entered normally.

Excel If Statement Logic

I have a dataset that contains all baseball games played for numerous years. I am attempting to create win/loss streaks. I want the formula to check that the team, and the year remain constant while a decision is made based on if the team won or not. I have the data sorted by Team, and the dates are chronological. Previously I had used a nested if statement when I just had the data for one year. The formula that I am attempting to use is
=IF(M6=M5, IF(C6=C5, IF(G6="W",1+R5,0)), IF(G6="W",1,0), IF(G6="W",1,0)
=IF(Team=AboveTeam, If(Year=Aboveyear, If(Result=win, 1+abovewinsteak)), IF(Result=win, 1, 0), IF(result=win,1,0)
But I am getting the error that I have too many arguments. Any help would be much appreciated.
The IF statement with the condition C6=C5 is the one that had one two few arguments. You can try it this way.
=IF(M6=M5, IF(C6=C5, IF(G6="W",1+R5,0), IF(G6="W",1,0)), IF(G6="W",1,0))
Here's a rewritten version with fewer if statements and no duplication
=IF(G6="W",1+( IF(AND(M6=M5,C6=C5),R5,0)), 0)
IF( Result=Win, 1 + ( IF ( Team=AboveTeam AND Year=AboveYear, AboveWinStreak, Year or Team don't match so start over at 0 ), 0 because Result=Loss )
The top level ‘IF’ statement has too many arguments. The last two IFs seem out of place to me. I’m not sure of your logic, but assuming that you have a bunch of conditions that need to be met, the excel ‘IF’ formula signature is of the form:
IF(condition, if_true, if_false)
So you always need to put the next ‘IF’ in place of either ‘if_true’ or ‘if_false’. Within each parentheses pair there should be just 3 arguments.
Also, the 2nd IF has too few arguments (no ‘if_false’).
So, assuming that the last two IFs are in error; I think your formula should be:
=IF(M6=M5, IF(C6=“W”, IF(C6=C5, 1+R5, 1), 0), 0)

Resources