excel formula error - too few arguments - excel-formula

I'm getting an error with this statement that I have too few arguments:
=IFS(AND(D8="Hourly Field",C8<24),
1,IFS(AND(D8="Hourly Field",C8>=24,C8<48),
2,IFS(AND(D8="Hourly Field",C8>=48,C8<108),
3,IF(AND(D8="Hourly Field",C8>=108),
4))
When I change from of the parentheses to square brackets, I get an error that this is not a formula:
=IFS(AND(D8="Hourly Field",C8<24),
1,IFS[AND(D8="Hourly Field",C8>=24,C8<48)],
2,IFS[AND(D8="Hourly Field",C8>=48,C8<108)],
3,IF(AND(D8="Hourly Field",C8>=108)),
4)
Can someone tell me what I'm missing?

With IFS() you do not need to nest others:
=IFS(AND(D8="Hourly Field",C8<24),1,AND(D8="Hourly Field",C8>=24,C8<48),2,AND(D8="Hourly Field",C8>=48,C8<108),3,AND(D8="Hourly Field",C8>=108),4)
Edit
Your formula can be shortened to:
=IF(D8="Hourly Field",IFS(C8<24,1,C8<48,2,C8<108,3,C8>=108,4))

Related

Exception from HRESULT: 0x800A03EC for Excel in powershell

I am having the worst luck with this line of code...
$Myexcel.visible = $true
$Myworkbook = $Myexcel.workbooks.add()
$Sheet1 = $Myworkbook.worksheets.item(1)
$Sheet1.name = "Summary"
$Sheet1.Cells.item(3, 3) = '=IF(B3>0,ROUND((B3/B16)*100),"N/A")&"%"'
Things I've tried:
Shifting/replacing all of the single quotes and double quotes in every configuration you can think of,
escaping all the special characters including the parentheses, the asterisks, the commas, the gt symbol, the percentage symbol, and the configurations of quotes,
and adjusting the scope of the cell (i.e. trying different cells, using a range instead of an item)
I had to make an account just to see if I could get some help on this one, I've spent way too much time trying to get it to work.
tl;dr
The error message isn't very helpful, and seems to be a pretty generic one that is given in a number of situations, but in your case the root cause is the ROUND function takes 2 arguments and you've only specified one.
Try this instead:
$Sheet1.Cells.item(3, 3) = '=IF(B3>0,ROUND((B3/B16)*100,2),"N/A")&"%"'
# add an argument here ^^
Long Version
I initially thought the problem was something to do with the .items part of your sample $Sheet1.Cells.item(3, 3) - I'm more familiar with just using $Sheet1.Cells(3, 3), but they both give the same error, as do the following attempts:
PS> $Sheet1.Cells.item(3, 3) = '=IF(B3>0,ROUND((B3/B16)*100),"N/A")&"%"'
OperationStopped: 0x800A03EC
PS> $Sheet1.Cells(3, 3) = '=IF(B3>0,ROUND((B3/B16)*100),"N/A")&"%"'
OperationStopped: 0x800A03EC
PS> $Sheet1.Cells(3, 3).Formula = '=IF(B3>0,ROUND((B3/B16)*100),"N/A")&"%"'
OperationStopped: 0x800A03EC
So as an experiment I tried manually pasting the formula into a new sheet and got this:
Microsoft Excel
You've entered too few arguments for this function.
[ Ok ]
Your root problem is the ROUND function takes 2 arguments - the value and the precision:
https://support.microsoft.com/en-us/office/round-function-c018c5d8-40fb-4053-90b1-b3e7f61a213c#:~:text=The%20ROUND%20function%20rounds%20a,of%20this%20function%20is%2023.78.
Syntax
ROUND(number, num_digits)
The ROUND function syntax has the following arguments:
number Required. The number that you want to round.
num_digits Required. The number of digits to which you want to round the number argument.
If you change your formula to, e.g.
=IF(B3>0,ROUND((B3/B16)*100,2),"N/A")&"%”
it should work fine.

Why am I getting a value error in excel while using the ifs function?

=IFS(SEARCH("C*",A9),"Cake",SEARCH("K*",A9),"Cookies",SEARCH("B*",A9),"Bread & Bun",SEARCH("Y*",A9),"Pastry")
It works for the first criteria and returns "cake" but won't work for the others. I keep getting a #VALUE error.
Can help please??
SEARCH isn't a Boolean-valued function. It doesn't return FALSE if the string isn't found -- it returns a #VALUE! error which isn't coerced to FALSE.
What you could do is wrap everything like SEARCH("C*",A9) with ISNUMBER(): ISNUMBER(SEARCH("C*",A9)) since Excel can tell that #VALUE! isn't a number.

Error with formula trying to use IF(AND with three conditions

I am trying to write a formula to evaluate all possible values in three cells and score them in another. Excel says that there is a problem with my formula, but I can't locate it. Your help is appreciated.
I am using IF(AND throughout my spreadsheet, but only with two values. Those formulas are accepted by Excel.
=IF(AND(B2="No",B3="Red",B5="No"),0,
IF(AND(B2="No",B3="Green",B5="No",2,
IF(AND(B2="No",B3="Blue",B5="No",3,
IF(AND(B2="No",B3="Yellow",B5="No",5,5,
IF(AND(B2="No",B3="Red",B5="Yes"),0,
IF(AND(B2="No",B3="Green",B5="Yes"),2,
IF(AND(B2="No",B3="Blue",B5="Yes",3,
IF(AND(B2="No",B3="Yellow",B5="Yes",5,
IF(AND(B2="Yes",B3="Red",B5="Yes",0,
IF(AND(B2="Yes",B3="Green",B5="Yes",1,
IF(AND(B2="Yes",B3="Blue",B5="Yes",2,
IF(AND(B2="Yes",B3="Yellow",B5="Yes",5,
IF(AND(B2="Yes",B3="Red",B5="No",0,
IF(AND(B2="Yes",B3="Green",B5="No",1,
IF(AND(B2="Yes",B3="Blue",B5="No",2,
IF(AND(B2="Yes",B3="Yellow",B5="No",3))))))))))))))))
Excel states "There is a problem with this formula".
You had a 5,5 where you should have had a 5 and where missing many ) to close the ANDs
=IF(AND(B2="No",B3="Red",B5="No"),0,
IF(AND(B2="No",B3="Green",B5="No"),2,
IF(AND(B2="No",B3="Blue",B5="No"),3,
IF(AND(B2="No",B3="Yellow",B5="No"),5,
IF(AND(B2="No",B3="Red",B5="Yes"),0,
IF(AND(B2="No",B3="Green",B5="Yes"),2,
IF(AND(B2="No",B3="Blue",B5="Yes"),3,
IF(AND(B2="No",B3="Yellow",B5="Yes"),5,
IF(AND(B2="Yes",B3="Red",B5="Yes"),0,
IF(AND(B2="Yes",B3="Green",B5="Yes"),1,
IF(AND(B2="Yes",B3="Blue",B5="Yes"),2,
IF(AND(B2="Yes",B3="Yellow",B5="Yes"),5,
IF(AND(B2="Yes",B3="Red",B5="No"),0,
IF(AND(B2="Yes",B3="Green",B5="No"),1,
IF(AND(B2="Yes",B3="Blue",B5="No"),2,
IF(AND(B2="Yes",B3="Yellow",B5="No"),3,""))))))))))))))))
But I think you can do this with a simpler formula:
=IFERROR(IF(B2 = "No",CHOOSE(MATCH(B3,{"Red","Green","Blue","Yellow"},0),0,2,3,5),IF(B5="Yes",CHOOSE(MATCH(B3,{"Red","Green","Blue","Yellow"},0),0,1,2,5),CHOOSE(MATCH(B3,{"Red","Green","Blue","Yellow"},0),0,1,2,3))),"")
You could put your logic in string form in one cell (say, F1):
0NOREDNO 2NOGREENNO 3NOBLUENO 5NOYELLOWNO 0NOREDYES 2NOGREENYES 3NOBLUEYES 5NOYELLOWYES 0YESREDYES 1YESGREENYES 2YESBLUEYES 5YESYELLOWYES 0YESREDNO 1YESGREENNO 2YESBLUENO 3YESYELLOWNO
Then your code reduces to:
=MID(F1, FIND(UPPER(B2&B3&B5),F1)-1, 1)
This would also make it extremely easy to add more conditions in the future.
Try this:
=IF(B3="Red",0,
IF(B3="Green",
IF(B2="Yes",1,
IF(B2="No",2,NA())),
IF(B3="Blue",
IF(B2="Yes",2,
IF(B2="No",3,NA())),
IF(B3="Yellow",
IF(AND(B2="Yes",B5="No"),3,5),
NA()))))
Hope that helps

If OR with RIGHT in Excel

This seems simple, but evidently incorrect. Have any ideas?
The data:
Cell J5 value is simply this URL:
www.url.com/at/
The logic: Check if cell J5 ends in "/at/" or if it ends in "de/", value if true for either one of those is 1, value if false for both is zero.
Here's the function I'm trying out:
=IF(OR(RIGHT(J5,4)=“/at/"),(RIGHT(J5,3)=“de/"),"1","0")
My result is #NAME?
The double bracket characters are incorrect (before the /at and before the de/). Make sure you use "" around string literals. Secondly the closing bracket is not required after the first RIGHT and does not need open bracket before the second right. With these corrections the formula becomes:
=IF(OR(RIGHT(J5,4)="/at/",RIGHT(J5,3)="de/"),"1","0")
Your command has incorrect parenthesis.
Your command:
IF(OR(RIGHT(J5,4)=“/at/"),(RIGHT(J5,3)=“de/"),"1","0")
OR(RIGHT(J5,4)="/at/") is the cause of output #NAME because OR in this case has only one operand.
You should not close the parenthesis here and should close it after the second operand.
Try:
IF(OR(RIGHT(J5,4)=“/at/",RIGHT(J5,3)=“de/"),"1","0")

How do I sum results of two if statements in the same cell?

I'm looking to have the results of two If statements calculated and added in the same cell. I'm getting #VALUE! error.
=IF(ISERROR(GETPIVOTDATA("Sum of CHARGES",'Ship City'!$A$3,"ship_city",$B$7,"carrier_type",$A$27,"INV_month_id",D$6,"INV_year_id",$D$5,"Company Name",$B29)),"",GETPIVOTDATA("Sum of CHARGES",'Ship City'!$A$3,"ship_city",$B$7,"carrier_type",$A$27,"INV_month_id",D$6,"INV_year_id",$D$5,"Company Name",$B29))+IF(ISERROR(GETPIVOTDATA("Sum of CHARGES",'Recipient City'!$A$4,"recipient_city",$B$7,"carrier_type",$A$27,"INV_month_id",D$6,"INV_year_id",$D$5,"Company Name",$B29)),"",GETPIVOTDATA("Sum of CHARGES",'Recipient City'!$A$4,"recipient_city",$B$7,"carrier_type",$A$27,"INV_month_id",D$6,"INV_year_id",$D$5,"Company Name",$B29))
=IF(ISERROR(GETPIVOTDATA("Sum of CHARGES",'Ship City'!$A$3,"ship_city",$B$7,"carrier_type",$A$27,"INV_month_id",D$6,"INV_year_id",$D$5,"Company Name",$B29)),"",GETPIVOTDATA("Sum of CHARGES",'Ship City'!$A$3,"ship_city",$B$7,"carrier_type",$A$27,"INV_month_id",D$6,"INV_year_id",$D$5,"Company Name",$B29))
+
IF(ISERROR(GETPIVOTDATA("Sum of CHARGES",'Recipient City'!$A$4,"recipient_city",$B$7,"carrier_type",$A$27,"INV_month_id",D$6,"INV_year_id",$D$5,"Company Name",$B29)),"",GETPIVOTDATA("Sum of CHARGES",'Recipient City'!$A$4,"recipient_city",$B$7,"carrier_type",$A$27,"INV_month_id",D$6,"INV_year_id",$D$5,"Company Name",$B29))
Your both IF functions return an empty string "". Using + operator with strings returns #VALUE!. There are different methods to fix it:
use 0 instead of ""
use SUM instead of + (it ignores strings).
And as #John Bustos mentioned in his comment, you can simplify your formula with
IFERROR(value,value_if_error)
IFERROR description

Resources