If statement not working in Spotfire - if-statement

I hope you can help I am attempting to use an If statement in Spotfire. What I am trying to achieve is this
I have 13 unique numbers and what I am trying to say is that if column [GL_ACCOUNT(2)] = any of these 13 numbers then return me "Not EFPIA" in my new calculated column 'GL Account Filter'
It works up to two numbers but once i increase the amount of numbers the formula will not work.
My Code is below. As always any help is greatly appreciated
if([GL_ACCOUNT(2)]="0063304000","0063401000", "0062001000", "Not EFPIA")

Without using TERR or JS or IronPY you'll have to explicitly OR these together. I think you are trying to do something like the IN clause in TSQL as explained here but I'm unaware of that functionality in Spotfire.
if([GL_ACCOUNT(2)]="0063304000" or
[GL_ACCOUNT(2)]="0063401000" or
[GL_ACCOUNT(2)]="0062001000", "Not EFPIA")
You can also do this with a CASE if that's more legible for you.
case
when [GL_ACCOUNT(2)] = "0063304000" then "Not EFPIA"
when [GL_ACCOUNT(2)] = "0063401000" then "Not EFPIA"
when [GL_ACCOUNT(2)] = "0062001000" then "Not EFPIA"
else NULL
end
Or with the OR....
case
when [GL_ACCOUNT(2)] = "0063304000" OR
[GL_ACCOUNT(2)] = "0063401000" OR
[GL_ACCOUNT(2)] = "0062001000" then "Not EFPIA"
else NULL
end

The expression can be used as
if([GL_ACCOUNT(2)] in "0063304000","0063401000", "0062001000", "Not EFPIA")

Related

How to give if condition for propercase and uppercase in sap crystal report

I am getting two values one is printing Cash and other is printing CASH in sap crystal report. Now, I want that wherever Cash is showing at that time value should be false while if CASH is printing then the value should show true. So, for that I added the formula but didnt work,
here is my formula,
if(ProperCase({TmpSalesBillInstallmentReport.PaymentType}) = true)
then {TmpSalesBillInstallmentReport.PaymentType}= '0'
else if(UpperCase({TmpSalesBillInstallmentReport.PaymentType}) = true)
{TmpSalesBillInstallmentReport.PaymentType} = '1'
This formula is not working, even getting error i.e. A Boolean Is Required Here(indicating on the first line)
I surfing in net but didnt get related question also.
IF {TmpSalesBillInstallmentReport.PaymentType} = "CASH" Then True ELSE False;
Note: A Crystal formula cannot assign a value to a database field. The field value is Read Only!
UpperCase() function is not a test that returns true or false. It simply returns the text argument after converting it to all upper case.
You might have a setting causing comparisons to be case insensitive.
See: http://www.plumblineconsulting.com/crystal-reports-and-case-sensitivity-of-database-records/

array formula is not working in google sheet

What I want to do:
Check if 4 of my cells are blank or not
If all of them are not blank, then its okay, else display nothing ("")
I want it to be auto dragged down
What I have tried
=arrayformula(if(AND(not(A1:D=""),not(B1:B=""),not(C1:C=""),not(D1:D="")),"ok",""))
Result
Although the statements of AND is true, it displays nothing ""
What can be the issue in the formula?
When we use AND() , OR() it won't work with array, I'm not sure why
But we can count true/false as a number of 1 = true and 0 = false
=arrayformula(if(not(A1:A="")+not(B1:B="")+not(C1:C="")+not(D1:D="")>3,"ok",))
AND is not supported in AF.
use in row 1:
=ARRAYFORMULA(IF((A1:A<>"")*(B1:B<>"")*(C1:C<>"")*(D1:D<>""); "ok"; ))

OBIEE Case Statement

I'm trying to use a Case formula to evaluate a date but it's erroring out every time. Not sure where I'm going wrong.
1/1/9999 is a date.
Code:
CASE
WHEN "Item "."Store OOS" = 1/1/9999
THEN 'repln'
ELSE 'Fashion'
END
CASE WHEN "Item"."Store OOS" = date '9999-01-01' then 'repln' ELSE 'Fashion' END

Only one IF ELSE statement working SAS

Can someone explain to me why only the first IF ELSE statement in my code works? I am trying to combine multiple variables into one.
DATA BCMasterSet2;
SET BCMasterSet;
drop PositiveLymphNodes1;
if PositiveLymphNodes1 = "." then PositiveLymphNodes =
put(PositiveLymphNodes2, 2.);
else PositiveLymphNodes = PositiveLymphNodes1;
if PositiveLymphNodes2 = "." then new_posLymph = put(PositiveLymphNodes,
2.);
else new_posLymph = PositiveLymphNodes2;
RUN;
Here is a nice screenshot of what the incorrect output looks like:OUTPUT
Thanks!
Hard to say without seeing all of your data, but I have a suspicion: is positivelymphnodes1 character or numeric? Is it ever actually equal to "."?
If you are trying to say "if PositiveLymphNodes1 is missing", then you can say that this way:
if missing(positivelymphnodes1) then ...
You can also do the same thing using coalesce or coalescec (the latter is character, the former numeric, in its return value). It chooses the first nonmissing argument. - so if the first argument is missing, it chooses the second.
positiveLymphNodes = coalescec(PositiveLymphNodes1, put(positiveLymphNodes2,2.));
new_posLymph = coalescec(positiveLymphNodes2, put(positiveLymphNodes,2.));
I would be curious why you're using put only in one place and not the other - use it in both or neither, I would suggest.

Crystal Reports Else If statement

I can't figure out why this if statement won't work.
I have a DateTime field DATEFROM and a String parameter (it HAS to be String) periodEnd.
I would like to calculate percentages depending if these two dates have 1, 2, 3 or more years difference.
When I use this formula I get either "100%" or "-" and never the other two options. It's like CR calculates the first IF and if it's true then: "100%" but if it's false, it never checks for the rest of the Else Ifs and goes dirreclty to Else
StringVar percentage:="";
If (cDate({?periodEnd})-{TABLE.DATEFROM})<=1 Then
percentage:="100%"
Else If (cDate({?periodEnd})-{TABLE.DATEFROM})<=2 Then
percentage:="66%"
Else If (cDate({?periodEnd})-{TABLE.DATEFROM})<=3 Then
percentage:="33%"
Else
percentage:="-"
Any idea?
a) I assume you already made sure your periodend format matches with what cdate interprets?
If you just subtract them, Crystal by default returns the number of days between.
Two ways you can do year:
datediff("yyyy",cDate({?periodEnd},{TABLE.DATEFROM})
or
year(cDate({?periodEnd})-year({TABLE.DATEFROM})
b) You've also no doubt accounted for when your {TABLE.DATEFROM} is greater than cDate({?periodEnd} and you have a negative result?
Not sure if the following is the behavior you would want, but I'm throwing it in for your information
ABS(datediff("yyyy",cDate({?periodEnd},{TABLE.DATEFROM}))
**make sure you check the help file for the datediff codes ("yyyy" etc) as they are not quite instinctive and can trip you up when you think you're using the obvious one