IBM Cognos prompt value when not entered - cognos

I have a problem in report studio. please help me to figure this out..
i have a optional prompt, i want to check whether the value is selected or not..
Please help how to check..
if (?parameter? is null ) then ('1') else ('2')
or
if (ParamDisplayValue('parameter') is null ) then ('1') else ('2')
Both the above are not working..
Suppose if i select any value in the prompt then the else part works and i get the result as 2, if i wont select anything then i'm not getting the result as 1

My guess, without doing extensive testing, is that an empty optional prompt doesn't exist at all and can't be compared to null. That said, I believe there's an easy fix.
Since you know that when you select an item '?parameter? is null' will return false, '?parameter? is not null' should return true and you can reverse the logic:
if (?parameter? is not null) then ('2') else ('1')

Try to put a conditional block. Set a block variable of type boolean with this expression:
ParamDisplayValue('myParam') is null
Then go to your conditional block again switch property "current block" to yes/no.
When yes (meaning that our block variable is true so the parameter is null) add a text item and just write "All".
When no add a text item with source type as report expression and write ParamDisplayValue('myParam')
P.S: there is also a way to count how many values the user selected (so as not to display all of them 1 by 1 but just show "62 values selected") but it needs some javascript and a hidden prompt field.

Use ParamCount
More details here:
http://joesanswers.blogspot.com.au/2008/09/checking-for-empty-parameters-in-cognos.html

Related

Cognos Report Studio: CASE and IF Statements

I'm very new in using Cognos report studio and trying to filter some of the values and replace them into others.
I currently have values that are coming out as blanks and want to replace them as string "Property Claims"
what i'm trying to use in my main query is
CASE WHEN [Portfolio] is null
then 'Property Claims'
ELSE [Portfolio]
which is giving me an error. Also have a different filter i want to put in to replace windscreen flags to a string value rather than a number. For example if the flag is 1 i want to place it as 'Windscreen Claims'.
if [Claim Windscreen Flag] = 1
then ('Windscreen')
Else [Claim Windscreen Flag]
None of this works with the same error....can someone give me a hand?
Your first CASE statement is missing the END. The error message should be pretty clear. But there is a simpler way to do that:
coalesce([Portfolio], 'Property Claims')
The second problem is similar: Your IF...THEN...ELSE statement is missing a bunch of parentheses. But after correcting that you may have problems with incompatible data types. You may need to cast the numbers to strings:
case
when [Claim Windscreen Flag] = 1 then ('Windscreen')
else cast([Claim Windscreen Flag], varchar(50))
end
In future, please include the error messages.
it might be syntax
IS NULL (instead of = null)
NULL is not blank. You might also want = ' '
case might need an else and END at the bottom
referring to a data type as something else can cause errors. For example a numeric like [Sales] = 'Jane Doe'
For example (assuming the result is a string and data item 2 is also a string),
case
when([data item 1] IS NULL)Then('X')
when([data item 1] = ' ')Then('X')
else([data item 2])
end
Also, if you want to show a data item as a different type, you can use CAST

OR Formula in Word document not returning a value

I am working on a document where I need to be able to test multiple options in an if statement to see if one of them are true to decide if a paragraph displays on the document. I have been trying to figure out why my OR formula is not returning a value for me to test and I am not sure why it is not showing anything when it is updating.
I have inserted a field and added a formula within that field that I am hoping will work with my If statement to show the proper paragraph contens.
When I use an Or statement, even one as simple as { OR(1=1) } and update and toggle the field I get no result. From what I have read I should get a 1 or a 0, but I don't seem to get either of these results. The line just ends up blank. When I test it with my If formula it always shows the false result, even when the Or contains a true result.
The formula I am currently working with is:
{ IF{ OR("$event.eventType.name}" = "Birthday", "$event.eventType.name}" =
"Conference" } "Yes" "No" }
If I update and toggle the Or field it shows blank, no result either true or false, and makes the If formula show as false event on results where it should show true. As I mentioned above I even tried setting it to 1=1 and still could not get it to show as true. Not sure if there is something I am missing in working with the formula.
Any suggestions would be appreciated.
It's not clear from your post what $event.eventType.name is. Presumably it's a field generated by an Addin. In that case, you should be able to use something like:
{IF{={IF{$event.eventType.name}= "Birthday" 1 0}+{IF{$event.eventType.name}= "Conference" 1 0}# 0}> 0 "Yes" "No"}
or:
{={IF{$event.eventType.name}= "Birthday" 1 0}+{IF{$event.eventType.name}= "Conference" 1 0} \# "'Yes',,'No'"}
Note: The field brace pairs (i.e. '{ }') for the above example are all created in the document itself, via Ctrl-F9 (Cmd-F9 on a Mac); you can't simply type them or copy & paste them from this message. Nor is it practical to add them via any of the standard Word dialogues. The spaces represented in the field constructions are all required. If your fields are a kind of mergefield, you'll need to insert 'MERGEFIELD ' at the start of each one, thus:
{MERGEFIELD $event.eventType.name}

Multiple nested If statement - And Or not working

Using a nested If Statement in Excel I have been trying to obtain results using the following criteria:
within 100 and 75000 Volts but should accept 11; 22; 25; 26; 30; 33; 66
as they will be in kV
Source data is in a table Transformers and the formula is also returning data on two other tables MASTER and META.
I have tried in vain all kinds of IF/AND/OR variants of the following, however I have rarely used nested if statements before so am not at home with the logic. Any help gratefully received !
Thank you
=IF(MASTER!N2="Failed Check 1","Failed Check 1",IF(META!N2="Failed Check 2","Failed Check 2"), IF(OR(Transformers!T2>=110, Transformers!T2<=75000) OR(Transformers!T2=11, Transformers!T2=22, Transformers!T2=25, Transformers!T2=26, Transformers!T2=30, Transformers!T2=33, Transformers!T2=66),"Failed Check 3","Passed Check 3"))
Thank you
It looks like you need an AND as the first term in your OR. The parenthesis also looked incorrect. Once the complexity reaches a certain stage it sometimes helps to compose the formulas in something like Notepad with white-space to display the logic:
=IF(MASTER!N2="Failed Check 1",
"Failed Check 1",
IF(META!N2="Failed Check 2",
"Failed Check 2",
IF(OR(
AND(Transformers!T2>=110, Transformers!T2<=75000),
Transformers!T2=11,
Transformers!T2=22,
Transformers!T2=25,
Transformers!T2=26,
Transformers!T2=30,
Transformers!T2=33,
Transformers!T2=66
),
"Failed Check 3",
"Passed Check 3"
)
)
)
Without linebreaks this is:
=IF(MASTER!N2="Failed Check 1","Failed Check 1",IF(META!N2="Failed Check 2","Failed Check 2", IF(OR(AND(Transformers!T2>=110, Transformers!T2<=75000),Transformers!T2=11, Transformers!T2=22, Transformers!T2=25, Transformers!T2=26, Transformers!T2=30, Transformers!T2=33, Transformers!T2=66),"Failed Check 3","Passed Check 3")))
=IF(MASTER!N2="Failed Check 1","Failed Check 1",IF(META!N2="Failed Check 2","Failed Check 2", IF(OR(Transformers!T2>=110, Transformers!T2<=75000, Transformers!T2=11, Transformers!T2=22, Transformers!T2=25, Transformers!T2=26, Transformers!T2=30, Transformers!T2=33, Transformers!T2=66),"Failed Check 3","Passed Check 3")))
Some problems in your formula:
before the second OR a comma is missing, it should be ),OR(
closing parenthesis of first OR is missing, it should be ...=66)),...
closing parenthesis of IF is missing, your formula should end to )))
+1 you are looking for values between 100 and 75000, this could be done with AND instead of OR
Another approach
To simplify your formula you can place your valid kV values in a range and refer to it; let's call it kVolts (one value per cell, either in one row or in one column)
The simplified formula:
=IF(MASTER!N2="Failed Check 1","Failed Check 1",IF(META!N2="Failed Check 2","Failed Check 2"), IF(OR(AND(Transformers!T2>=110, Transformers!T2<=75000),IFERROR(MATCH(Transformers!T2,kVolts,0)>0,FALSE)) ,"Failed Check 3","Passed Check 3")))
Based on your conditions, I would recommend you implement this one liner which assumes your data is in cell A1.
=IF(OR(AND(A1>=100,A1<=75000),A1=11,A1=22,A1=25,A1=26,A1=30,A1=33,A1=66),TRUE,FALSE)
Although this only returns TRUE or FALSE, which doesn't tell you which check it has passed.

Nested IF statement returning false

I have a nested if statement is returning "False" rather than the expected outcome.
Scenario
Table "High VoltageCables" has data in it that default to numeric but may contain characters: kVa
Table "Master" checks "High VoltageCables" data as blank or not blank, and returns "Failed Check 1","Passed Check 1". This works fine.
Table "Meta" then checks the results of "Master" and then tests "High VoltageCables" data for length between 1 and 6, regardless of whether record is numeric or string.
Formula
=IF(MASTER!H2="Passed Check 1",IF(LEN('High VoltageCables'!O2)>=1,IF(LEN('High VoltageCables'!O2<6),"Passed Check 2","Failed Check 2")))
This is partially succesful, as it returns "Passed Check 2" for the following sample data in the source table "High VoltageCables".
1 numeric, or
1kVa str, or
50000 numeric
However if a field in "High VoltageCables"is blank, the formula returns "FALSE" rather than "Failed Check 1"
I inherited this task, (and would have preferred to do the whole thing in Access using relatively simple queries) - and unfortunately I am new to nested If statements, so I am probably missing something basic...
NB the data in High VoltageCables must default to numeric for a further check to work.
The first and second IF's seem to be missing the else part. They should be added at the end between the ))) like ), else ), else )
Every IF statement consists of IF( condition, truepart, falsepart) if you have two nested ifs it will be something like IF( condition, IF( condition2, truepart2, falsepart2), falsepart)
Hope that makes it a little clearer
You do have an unaccounted for FALSE in the middle IF. Try bring the latter two conditions together.
=IF(Master!H2="Passed Check 1",IF(OR(LEN('High VoltageCables'!O2)={1,2,3,4,5}),"Passed Check 2","Failed Check 2"))
It's still a bit unclear on what to show or not show if Master!H2 does not equal "Passed Check 1".
I failed to construct the formula with a concluding "else" - "Failed Check 1"
Using jeeped's and Tom's suggestion and adding the final "else" part I have solved the problem:
=IF(MASTER!H2="Passed Check 1",IF(OR(LEN('High VoltageCables'!O2)={1,2,3,4,5}),"Passed Check 2","Failed Check 2"),"Failed Check 1")

How to verify ANY text is present with selenium IDE

I know how to verify if a specific text is present in a web page using Selenium IDE. But what I wanted to know is, can you verify that any text is present in an element?
For example there's a text box with the title "Top Champion". This text box will be changed daily with the name of a person. Now I just wanted to check whether there is a text in this text box, no matter what the text actually is. I've tried the verify text command and tried blanking the value, but it doesn't work. If the command can return a true or false command that would be really helpful
BTW, verify value doesn't work either since the element that I'm testing is not a form field
Your best bet is as follows (I have written single tests for this for numbers)
Medium rigour:
waitForText | css=.SELECTORS | regex:.+?
This will wait until there is at least 1 character present.
Strong rigour (only works if you have a subset of characters present):
waitForText | css=.SELECTORS | regex:^[0-9]+$
This will wait until there is text. This text must start with a number, have at least 1 number, and then finish. It does not permit any character outside of the subset given. An example you could do to match numbersNAMEnumbers would be.
waitForText | css=.SELECTORS | regex:^[0-9]+[a-zA-Z]+[0-9]+$
This would wait for a string such as 253432234BobbySmith332
Luke
If i have understood your question properly there below is one way you can search for an element contains a string. Not sure if this is what you are looking.
List<WebElement> findElement = webElement.findElements(By.xpath("YOUR_TEXTINPUT_PATH_HERE"));
if( findElement.size() > 0 ){
if( findElement.get(0).getText() != null && findElement.get(0).getText().indexOf("THE_STRING_THAT_YOU_WANT_TO SEARCH") != -1 ) {
// IF IT COMES HERE, THAT MEANS THE ELEMENT IS PRESENT WITH THE TEXT
}
}
store text|[your element]|StoredText
execute script|return ${StoredText}.length > 0|x
assert|x|true
Using these three lines in the Selenium IDE, the first line will extract the text from the element into the variable StoredText.
The second line will store whether the length of that text is greater than zero into the variable x (a true or false result).
The third line asserts that the result was true, failing the test if not. You don't need the third line if all you want is the true or false result.
So if the element contains any text, the extracted text length will be greater than zero, the variable x will be true, and the assert will pass. This verifies that any text is present in the element.

Resources