I am having IF THEN ELSE error using Parameters - cognos

I have an expression that says:
IF (?Quarter Selection? = 'PY 2017 Q3'
AND ?Type of Report? = 'Exiter Report')
THEN ([Seeker Status Date] BETWEEN TO_DATE('10/01/2017', 'MM/DD/YYYY')
AND TO_DATE('12/31/2017', 'MM/DD/YYYY'))
ELSE (1=1)
I get a host of errors when I validate it. If I take out one of the parameters in the IF section, it works fine. Example:
IF (?Quarter Selection? = 'PY 2017 Q3')
THEN ([Seeker Status Date] BETWEEN TO_DATE('10/01/2017', 'MM/DD/YYYY')
AND TO_DATE('12/31/2017', 'MM/DD/YYYY'))
ELSE (1=1)
Can you not have more than one parameter in the statement?

You are trying to return conditional expressions.
[Seeker Status Date] BETWEEN TO_DATE('10/01/2017', 'MM/DD/YYYY')
AND TO_DATE('12/31/2017', 'MM/DD/YYYY')
and
1=1
are not values.
Try returning values in the THEN and ELSE parts of the statement.

Related

Trying to write a simple computed column expression (IF Statement)

I have a column in my table called "BanquetPrize" and another column called "PrizeWinner." If the "BanquetPrize" field is NOT NULL, I'd like the "PrizeWinner" field to auto-fill with "YES," and if it IS NULL, it should be "NO." (Persisted)
I'm really new to SQL and coming from DBF tables where the expression would have been:
IF(IsNotBlank(BanquetPrize), "YES", "NO")
But I can't figure out how to write it in SQL. What I've tried:
(IIF [BanquetPrize]isnotnull then 'YES' else 'NO' end)
-- and also --
(case when [BanquetPrize]isnotnull then 'YES' else 'NO' end)
Obviously the syntax was wrong with both of these, so I was hoping someone could educate me on the correct way to write it?
In SQL You want to use IS NULL as shown in the following code
CASE [BanquetPrize]
WHEN IS NULL THEN 'NO'
ELSE 'YES'
END
You can also do something like the following to give the return column a name, in this case I am giving it a name same as column which is BanquetPrize
CASE [BanquetPrize]
WHEN IS NULL THEN 'NO'
ELSE 'YES'
END AS 'BanquetPrize'
Additional Example when using CASE in ORDER BY Clause
SELECT CustomerName, City, Country
FROM Customers
ORDER BY
(CASE
WHEN City IS NULL THEN Country
ELSE City
END);
Read more about SQL CASE statement and using IS NULL here https://www.w3schools.com/sql/sql_case.asp
You can use CASE or IIF
CASE
SELECT BanquetPrize, CASE WHEN BanquetPrize IS NOT NULL THEN 'YES' ELSE 'NO' END as PrizeWinner
FROM t1;
IIF
SELECT BanquetPrize, IIF(BanquetPrize iS NOT NULL,'YES','NO') as PrizeWinner
FROM t1;
Demo

Combining two separate case statements in NetSuite Case Statements

I currently have two separate saved search columns for these two statements, and I'm hoping to combine them and list the data in just one column. I've tried OR AND, but the results then error out.
First Statement
Case when {item.custitem54} is null then {quantity} else null end
Second Statement
Case when {item.custitem54} = 'Yes' and {shipdate} between to_date('05/25/2020', 'MM/DD/YYYY') and to_date('12/25/2020', 'MM/DD/YYYY') then {quantity} else null end
You can have multiple WHEN in a case statement. The first matched WHEN determines the result unless it gets to the ELSE.
Case when {item.custitem54} = 'Yes'
and {shipdate} between date '2020-05-25' and date '2020-12-25' then {quantity}
when {item.custitem54} is null then {quantity}
else null
end

NetSuite Case when statement on joined

I'm new to writing case statements in NetSuite and would appreciate any input with this. I'm trying to create following statement within item search, but receiving invalid expression error.
CASE WHEN {transaction.status} = "Purchase Order:Pending Receipt" THEN {transaction.expectedreceiptdate} end
CASE WHEN {transaction.status} = 'Pending Receipt' THEN {transaction.expectedreceiptdate} end
Note that you need to use single quotes in SQL statements, and you can't specify the transaction type as part of the status condition. To work araound this, you could include the transaction type in the criteria, or add another condition within the CASE statement:
CASE WHEN {transaction.status} = 'Pending Receipt' AND {transaction.type} = 'Purchase Order' THEN {transaction.expectedreceiptdate} end

If Then Else in Infopath (Xpath): how to ?

I've a module in InfoPath / Sharepoint, a query field, and some fields.
I want to perform in formula a simple :
If (Condition) then
True Condition
Else
False Condition
In particular I want to write this formula:
If (FieldA = "") then
Get FieldB
else
Get FieldA
How to do in InfoPath formula ?
Thanks
If you want to use this as a default value, you can simply use the conditional default values. Therefor just use the following snippet:
(TrueResult | ElseResult) [(BoolCondition) + 1]
And in your case:
(FieldA | FieldB) [(string-length(FieldA) > 0) + 1]
For more information on this see:
https://blogs.msdn.microsoft.com/infopath/2006/11/27/conditional-default-values/

Using a case when result for comparison in another case when in NetSuite

I am trying to run an equation on a saved search in NetSuite that uses a formula, and a field.
I can run this and I get the correct value:
CASE WHEN {systemnotes.context}='UI' AND {systemnotes.field}='Date Closed' THEN {systemnotes.newvalue} END
And, this returns the correct value:
{startdate}
But, I can not figure out how to say that if the first case does not return a null value, and the second one is not null then give me the difference between the two. I was trying something like this (in many different variations:
CASE WHEN [(CASE WHEN {systemnotes.context}='UI' AND {systemnotes.field}='Date Closed' THEN {systemnotes.newvalue} END) IS NOT NULL AND {startdate} IS NOT NULL] THEN
{CASE WHEN {systemnotes.context}='UI' AND {systemnotes.field}='Date Closed' THEN {systemnotes.newvalue} END)-{startdate}
END
Every time I run it I get invalid expression. I've Googled around adn con not seem to find anything that discusses this type of operation, though.
The formula below worked for me. I couldn't tell what recordtype you were running against so I just added a custom date field to the case record called Test Date Field. Just replace the field name with yours and it should work.
The key is that {systemnotes.newvalue} returns text so you need to wrap that result in TO_DATE() to convert it. Then you can subtract {startdate} from it.
Your column type should be Formula(numeric).
case when
(CASE WHEN {systemnotes.context}='UI' AND {systemnotes.field}='Test Date Field' THEN {systemnotes.newvalue} END is not null and {startdate} is not null)
then (TO_DATE(CASE WHEN {systemnotes.context}='UI' AND {systemnotes.field}='Test Date Field' THEN {systemnotes.newvalue} END) - {startdate}) END

Resources