I keep getting #NA - google-sheets

=IF(and(or(U3="Pro",U3="Standard"),T3>0,"Charged",If(and(U3="Lite",T2.+0),"Charged","FOC")))
Got a #NA Error
Wrong number of arguments to IF. Expected between 2 and 3 arguments, but got 1 arguments.

If I don't misunderstand what you're trying to achieve, you're missing a parenthesis after T3>0 in order to close the AND clauses:
=IF(and(or(U3="Pro",U3="Standard"),T3>0),"Charged",If(and(U3="Lite",T2.+0),"Charged","FOC"))
And I don't know what you meant with "T2.+0"

Try ifs(), like this:
=ifs(
T3 = "", iferror(1/0),
T3 < 0, "Reimbursement",
T3 = 0, "Free of charge",
true, "Charged"
)

use:
=IF(AND(OR(U3="Pro", U3="Standard"), T3>0), "Charged",
IF(AND(U3="Lite", T2+0), "Charged", "FOC"))
or:
=IF((REGEXMATCH(U3, "Pro|Standard"))*(T3>0), "Charged",
IF((U3="Lite")*(T2+0), "Charged", "FOC"))

Related

QUERY simplification with LAMBDA function

I have this formula so I want to make the same QUERY for each variable and join the results. The given formula works (no error in cell) but it give me only the first query result.
I want the result to be QUERYRESULT1 / QUERYRESULT2 / QUERYRESULT3, etc. and i could repeeat the query for each variable, but I'm asking for a way to make it with only one line (to simplify). Is it possible?
=MAP(
BI3:BI;BL3:BL;BO3:BO;BR3:BR;BU3:BU;BX3:BX;CA3:CA;CD3:CD;CG3:CG;CJ3:CJ;CM3:CM;CP3:CP;
LAMBDA(f;g;h;i;j;k;l;m;n;o;p;q;
TEXTJOIN(" / "; TRUE;
IFNA(
ARRAYFORMULA(
IFERROR(QUERY('BDD Componentes'!AR:AV;"SELECT AV WHERE AR = '"&{f;g;h;i;j;k;l;m;n;o;p;q}&"'";0))
)
)
)
)
)
here I am with the same suggestion as in your previous question. Try it and let me know:
=BYROW({BI3:BI\BL3:BL\BO3:BO\BR3:BR\BU3:BU\BX3:BX\CA3:CA\CD3:CD\CG3:CG\CJ3:CJ\CM3:CM\CP3:C};
LAMBDA(r;
TEXTJOIN(" / "; TRUE;
IFNA(
ARRAYFORMULA(
IFERROR(QUERY('BDD Componentes'!AR:AV;"SELECT AV WHERE AR = '"&r&"'";0))
)
)
)
)
)

How to ArrayFormula in Google Sheets with multiple IF AND OR conditions?

Can someone please help me?
I can't get seems to work it.
What else should I do?
Here is my code
=ARRAYFORMULA(IF(AND(Y2:Y="VUL",L2:L="ANNUAL"),V2:V*0.03,IF(AND(Y2:Y="VUL",L2:L="QUARTERLY"),V2:V>0,IF(AND(Y2:Y="VUL",L2:L="SEMI ANNUAL"),V2:V*AB2:AB,"0"))))
The results must be from 2nd row to last but only works only for 2nd row.
Use ifs(), like this:
=arrayformula(
ifs(
Y2:Y <> "vul", iferror(1/0),
L2:L = "annual", V2:V * 0.03,
L2:L = "quarterly", V2:V > 0,
L2:L = "semi annual", V2:V * AB2:AB,
true, iferror(1/0)
)
)
use:
=ARRAYFORMULA(IF((Y2:Y="VUL")*(L2:L="ANNUAL"), V2:V*0.03,
IF((Y2:Y="VUL")*(L2:L="QUARTERLY"), V2:V>0,
IF((Y2:Y="VUL")*(L2:L="SEMI ANNUAL"), V2:V*AB2:AB, "0"))))
AND is *
OR is +
Got the rights answer
thank you so much guys
=ARRAYFORMULA(IF((Y2:Y="VUL")*(L2:L="ANNUAL"),V2:V*0.03,
IF((Y2:Y="VUL")*(L2:L="QUARTERLY")*(V2:V>0), V2:V*AB2:AB,
IF((Y2:Y="VUL")*(L2:L="SEMI ANNUAL")*(V2:V>0), V2:V*AB2:AB, "0"))))

Error Message Saying "TweenInfo.new first argument expects a number for time," when using TweenInfo

I am making a tween, and I am getting an Error Message saying that "TweenInfo.new first argument expects a number a number for time," what is wrong?
local tweenInfo = TweenInfo.new{
0.75,
Enum.EasingStyle.Sine,
Enum.EasingDirection.Out,
0,
false,
0
}
-- later on when I call it
tweenService:Create(v, tweenInfo, Vector3.new(X,Y,Z)) -- v is an Instance of a Part
please help me!
You've run into a fun quirk of the lua language. As it turns out, parentheses are optional in function calls when only one argument is supplied.
So what is actually happening in your code is this ...
local tweenInfo = TweenInfo.new(
{ table of arguments }, -- time
nil, -- easing style
nil, -- easing direction
nil, -- repeat count
nil, -- reverses
nil -- delay
)
The TweenInfo constructor is expecting a number for the first argument, and instead it's getting a table of values.
So to fix this, just replace the curly brackets with parentheses:
local tweenInfo = TweenInfo.new(
0.75,
Enum.EasingStyle.Sine,
Enum.EasingDirection.Out,
0,
false,
0
)
--Edit : according to the comments, there was also a syntax error in TweenService:Create(). I've posted the fix here should others need it as well.
tweenService:Create(v, tweenInfo, {
Position = Vector3.new(X,Y,Z),
})

How to 'unpack' table into function arguments

I'm trying to call a function in Lua that accepts multiple 'number' arguments
function addShape(x1, y1, x2, y2 ... xn, yn)
and I have a table of values which I'd like to pass as arguments
values = {1, 1, 2, 2, 3, 3}
Is it possible to dynamically 'unpack' (I'm not sure if this is the right term) these values in the function call? Something like..
object:addShape(table.unpack(values))
Equivalent to calling:
object:addShape(1, 1, 2, 2, 3, 3)
Apologies if this is a totally obvious Lua question, but I can't for the life of me find anything on the topic.
UPDATE
unpack(values) doesn't work either (delving into the method addShape(...) and checking the type of the value passed reveals that unpackis resulting in a single string.
You want this:
object:addShape(unpack(values))
See also: http://www.lua.org/pil/5.1.html
Here's a complete example:
shape = {
addShape = function(self, a, b, c)
print(a)
print(b)
print(c)
end
}
values = {1, 2, 3}
shape:addShape(unpack(values))
Whoever comes here and has Lua version > 5.1 unpack is moved into the table library so you can use: table.unpack
For more info: https://www.lua.org/manual/5.2/manual.html
This is not an answer about unpack, but a suggestion to use a different technique. Instead, do
function object:addShape(values)
for i,v in ipairs(values) do
x,y = v.x, v.y
...
end
end
function getPairs(values)
xyPairs = {}
for i=1,#values,2 do
v = {x=values[i], y=values[i+i] }
table.insert(xyPair, v)
end
return xyPairs
end
values = {1, 1, 2, 2, 3, 3}
object:addShape(getPairs(values))
The amount of work to be done should be similar as unpacking and the additional processing you will have to do in addShape() to support variable number of named arguments.

Firebird SQL using <if> in <where>

I try to construct a SP in FB 2.5 that looks like that:
where
(
(kunde between :kdvon and :kdbis)
and
(AdrGrp between :AdrGrpvon and :AdrGrpbis)
and
(auftragstyp between :AuftrTypVon and :AuftrTypBis)
and
(Status between :statusvon and :statusbis)
and
IF LFDNR <> 0 THEN (LFDNUMMER = :LFDNR)
IF BESTELLTAG <> 0 then (bestelldatum = :BESTELLTAG)
)
It worked well until the If Statements were inserted.
After that I get the message
SQL error code = -104.
Token unknown - line 156, column 14.
LFDNR.
The IF conditions are defined as Input Parameters. Using the colon : to mark them as parameters did not work.
Question
Is it possible to use "If" inside "Where" in this way?
How do I have to use the condidional params?
TiA
Rolf
Try this instead:
...
AND (LFNDR = 0 OR LFDNUMMER = :LFDNR)
AND (BESTELLTAG = 0 OR bestelldatum = :BESTELLTAG)
(I don't know if LFNDR and BESTELLTAG are parameters/variables or columns in the = 0 clause - if they are parameters (the same as the right hand part), you should probably mark them with a ':')

Resources