I am trying to add some logic to my expression table (exp_source). Basically, if the field o_field_digital__c is 'Yes' then change it to 'Y'. If its 'No' then change it to 'N' and if it's Null then just leave it blank. I put in the following and its showing syntax error
IIF(o_Field_DRC_Choice_Eligible__c = 'Yes', 'Y')
IIF(o_Field_DRC_Choice_Eligible__c = 'No', 'N')
Can you please fix this? Do I only need one IIF statement? this obviously has syntax errors
First you need to understand it is a transformation not a table.
Second, you can't change the value of an input port - you can only create a new calculated variable or output port
Last... IIF syntax is
IIF(condition, return true, return false)
As you can see you haven't provided a value for the return false argument which ironically is where you should have nested the subsequent IIF. Also you will have to specify to otherwise leave blank in the missing return part of the nested IIF.
to correct you will need to nest them so
IIF(o_Field_DRC_Choice_Eligible__c = 'Yes', 'Y', IIF(o_Field_DRC_Choice_Eligible__c = 'No', 'N', ''))
You can use the below logic for the purpose, if none of the condition is matched it will default the output to blank:
DECODE(true,
o_Field_DRC_Choice_Eligible__c = 'Yes','Y',
o_Field_DRC_Choice_Eligible__c = 'No', 'N',
ISNULL(o_Field_DRC_Choice_Eligible__c),'',
'')
Related
I want to have the output of either true or false.
I have this syntax
.[] | (if (select(.displayName=="display")) then "yes" else "no" end)
This is the json source
[{"displayName":"display","message":"bla bla"}, {"displayName":"test","message":"bla bla"}]
I only need to query against the array and if the value im looking for exists in one of them I need the output to be "yes", and if it doesnt a "no". So a single output value is what I am looking for.
This evaluates to "yes", however, if the value display is not present in the json, it does not output "no", its just empty. Can anyone tell me why?
Here is a snippet to try: https://jqplay.org/s/WKcZh91hk8L
The idea is right, but you shouldn't be using select for this. The way select works is by evaluating the boolean expression provided inside (..) and returning the object, if the expression evaluates to true and skip the object from being considered/printed on false.
On your code, for the object that evaluates to false, select is evaluated as select(false) which as explained above returns nothing - this is not evaluated to boolean false condition. i.e. the return value of select is not a boolean value.
To use explicit boolean conditions, drop the select from expression and to summarise the result to a single value do something like below
if ( [ .[] | .displayName == "display" ] | any ) then "yes" else "no" end
Demo on jqplay
The way this works, is any can evaluate an array of boolean values and produces true as output if any of the elements of the array are true. We collect the match condition results to the array and apply any on it. i.e. [true, false] evaluates to true, thereby printing yes only once
A concise solution is possible with select:
select( any(.displayName=="display") ) | "yes" // "no"
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/
Multiple IF statements are giving me a FALSE response instead of the requested BLANK.
I figured that the last of the IF statements that has a "" would give BLANK if none of the conditions are met.
I've tried isolating each IF to see if I'm missing a statement but I don't see it.
Here is my formula:
=IF((LEFT(D5,2))=H2,IF(C5="Yearly",G5,IF(C5="Fixed Monthly",G5/12,"")))
How can I modify this formula so that it does not give me a FALSE and instead gives me a BLANK as requested on the 3rd IF statement.
Thank you.
You may an else condition to the first if statement:
Here is my formula:
=IF(LEFT(D5,2)=H2, IF(C5="Yearly",
G5,
IF(C5="Fixed Monthly",G5/12,"")),
"") <-- add this
My guesd is that because you did not specify an explicit else condition, Excel is defaulting to showing FALSE.
enter image description here
I have defined a python dictionary named "values" as shown above and it has several rows. I am trying to access the key:value pair for each row one by one if the key named "Risk: is high. I tried something like :
for i in range(len(rows)-1):
a = []
if values["Risk"][i]=='high':
a.append(values[key][i])
But the problem is it just appends the first character of each value. So instead of getting the vale 'Male' against the key 'Gender', I got 'M'. I am new to python and don't really understand the issue here.
Any suggestions?
Thanks!!
I know that this isn't a direct answer to your question, but I think you are having difficulties because of the way you are storing the "loaner" information. If you switched to a class-based model everything would get easier, more intuitive, and less hard-coded:
class LoanInfo(object):
__slots__ = ["HairLength","Employed","Age","Student",
"PreviouslyDeclined","Risk","FirstLoan","Gender",
"TypeOfColateral","LifeInsurance"]
def __init__(self,HairLength,Employed,Age,Student,PreviouslyDeclined,Risk,FirstLoan,Gender,TypeOfColateral,LifeInsurance):
self.HairLength = HairLength
self.Employed = Employed
self.Age = Age
self.Student = Student
self.PreviouslyDeclined = PreviouslyDeclined
self.Risk = Risk
self.FirstLoan = FirstLoan
self.Gender = Gender
self.TypeOfColateral = TypeOfColateral
self.LifeInsurance = LifeInsurance
loan_info_1 = LoanInfo('Short', 'Yes', 'Young', 'No', 'No', 'high', 'No', 'Male', 'Car', 'Yes')
loan_info_2 = LoanInfo('Short', 'Yes', 'Young', 'No', 'No', 'high', 'Yes', 'Male', 'Car', 'No')
loaners = [loan_info_1, loan_info_2]
rows = loan_info_1.__slots__ #<-- the slots of the object are the rows you want
high_risk_genders = []
for loaner in loaners:
if loaner.Risk == 'high':
high_risk_genders.append(loaner.Gender)
print high_risk_genders
output:
['Male', 'Male']
This is a more pythonic way of handling your problem. There is a lot of help online for python classes such as http://www.tutorialspoint.com/python/python_classes_objects.htm
After spending a while, you should think how to get data from a source you're using, because they're inadequate to calculate on them. I wish to help you, but I think that if I'll know the source from you get items from both dict and rows I will solve this issue totally different. If you want to solve this issue and it's really valuable for you, then just add more data to your question. That's all I can write.
I'm currently trying to validate if a string is exactly true or false as I'm building a spreadsheet importer using CF10.
My users will either enter in one of the following.
NULL, which will equate to false
TRUE which obviously equates to true
FALSE which again will equate to false.
I'm trying to use the isValid('boolean',variable.data) to validate if the data is in fact a boolean string or not. However after reading quite a few posts I can see that it will validate true if its a positive number and false if it is a negative one etc.
I'm wondering if anyone has an easy fix to getting boolean validation working for strings easily ? Is this more a regular expressions scenario to make it work properly ?
Any help greatly appreciated.
Assuming you mean the literal string "NULL", one option is using list functions. Search a list of allowed values, ie "true,false,null". If the entry is found, it is valid:
<cfif listFindNoCase("true,false,null", theValue)>
this is a valid boolean value
<cfelse>
not found. do something here...
</cfif>
Then a simple string comparison would return false for everything other than the literal string "true":
isTrue = compareNoCase(e, "true") eq 0 ? true : false`
If you need to evaluate whether a string is exactly "true" or "false", then you are not doing a boolean comparison, you are doing a string comparison.
So to that end, you'd be wanting to use compare() or compareNoCase() (depending on how rigid you need to be).
You could just do some logic or am I missing something.
<cfset booleanResult = enteredValue eq 'TRUE' ? true : false />