Can someone help me determine which I should be using?
Here is the situation - I am pulling a value from a column in the Data Table. If there is anything in that column, I set the data to a variable and take an action. If the column is blank, I want to skip that.
I am confused as to which IsWHATEVER statement would be best. For Example:
If IsEmpty(Datatable.Value("M4","Data_Entry"))=False Then
OR
If IsNull(Datatable.Value("M4","Data_Entry"))=False Then
OR
If IsNothing(Datatable.Value("M4","Data_Entry"))=False Then
Suggestions?
I've just tried all of your options and found this to be the most correct:
If (DataTable.Value("M4","Global") <> "") Then
Your original options will not work on QTP Datatables as these are for uninitialised objects or variables. However, in QTP as soon as you create a parameter in the Datatable the first value gets initialised as blank (not to be confused with empty).
I agree with shreyansp.. The 3 options are for variables and objects
You could also use the below expression
If len(trim(DataTable.Value("M4","Global"))>0 Then
'Do code here
End If
Related
ElasticSearch query works when hard coded, but fails when using Grafana variable value substitution:
Query: +nginx.access.upstream.response: [*, 1**, 2**, 3**, 4**, 5**, 500]
Each of these queries work when you hard code those values in the query.
Example Query: +nginx.access.upstream.response: 1**
^That works shows a table of data instead of "No data to show"
Although that works, it's better to use a variable with 7 values allows you to use 1 panel to display the same data that could be put in 7 hard coded panels, so that you end up with a cleaner user interface.
The problem is now that you've switched the hardcoded values to variable populated values the query no longer works.
The plugged in variable values [* and 500] work
The plugged in variable values [1**, 2**, 3**, 4**, 5**] don't work / result in "No data to show" as seen above.
There's something funny going on when the values get substituted into the query.
Q1.) What's the best tool/method to debug the true value of the variable after substitution/Figure out why it' failing?
Q2.) What's a method of fixing it/achieving the desired end result?
Q1.) What's the best tool/method to debug the true value of the variable after substitution/Figure out why it' failing?
Answer 1: Query Inspector
1** --when substituted becomes--> 1\\*\\*
which explains why it didn't work
Q2.) What's a method of fixing it/achieving the desired end result?
Answer 2: What worked for me was to avoid using the special character * in the variable values.
I rename the variable to HTTP Code Prefix and used the values [*,1,2,3,4,5]
I then used the Query: +nginx.access.upstream.response: $http_code_prefix*
I've been trying to use the following X-Path within Google-Sheets with the =ImportXML function
=importXml("http://www.managetickets.com/morecApp/ticketSearchAndStatusTicketList.jsp?msgCount=23&outputEmail=&db=nd", "/table[2]/tbody/tr#[td]")
But no matter what minor adjustments I try I continually get "#N/A" with a hover-text box that says "imported content is empty".
I know it's a valid x-path, I've cross verified it with 'X-Path Helper Wizard' chrome-extension.
Any ideas what I'm doing wrong!?
No, actually it's not a valid XPath. Note that # used to select an attributes e.g. #class, #id, etc. Also it's a bad idea to use tbody tag in your expressions as this tag is not always present in initial source code
So if you want to match table rows which contain cells from second table, you can use
/table[2]//tr[td]
My problem is that I can't get the IF condition to work in powerpivot (using DAX).
According to manual the syntax is:
IF(logical_test>,, value_if_false) where I can omitt the "value if false" if i want.
I have a lot of columns and I try to make a new one based on condition from another column.
What I tried is =IF([TimeTypeCode]="400", [WorkingHours]) and that doesn't work. What I want my condition to do is that if [TimeType] is equal to 400, then i want to put the value from [WorkingHours] in my new column. How can i do this?
from what I see here the problem is the ="400", the "" you used tell dax thats a string type and you are trying to use it as a numeric value.
Try using
IF([TimeTypeCode]=400, [WorkingHours])
instead,
Cheers!
Am trying to read the lotus notes document using VB6.I can able to read the values of the but suddenly type mismatch error is throwed.When i reintialise the vb6 variable it works but stops after certain point.
ex; address field in lotus notes
lsaddress=ImsField(doc.address)
private function ImsField(pValue)
ImsField=pValue(0)
end function
Like this I am reading the remaining fields but at certain point the runtime error "13" type mismatch error throwed.
I have to manually reintialize by
set doc=view.getdocumentbykey(doclist)
The type mismatch error occurs for a certain field. The issue should be a data type incompatibility. Try to figure out which field causes the error.
Use GetItemValue() instead of short notation for accessing fields and don't use ImsField():
lsaddress=doc.GetItemValue("address")(0)
The type mismatch is occurring because you are encountering a case where pValue is not an array. That will occur when you attempt to reference a NotesItem that does not exist. I.e., doc.MissingItem.
You should not use the shorthand notation doc.itemName. It is convenient, but it leads to sloppy coding. You should use getItemValue as everyone else is suggesting, and also you should check to see if the NotesItem exists. I.e.,
if doc.hasItem("myItem") then
lsaddress=doc.getItemValue("myItem")(0)
end if
Notes and Domino are schema-less. There are no data integrity checks other than what you write yourself. You may think that the item always has to be there, but the truth is that there is nothing that will ever guarantee that, so it is always up to you to write your code so that it doesn't assume anything.
BTW: There are other checks that you might want to perform besides just whether or not the field exists. You might want to check the field's type as well, but to do that requires going one more level up the object chain and using getFirstItem instead of getItemValue, which I'm not going to get into here. And the reason, once again, is that Notes and Domino are schema-less. You might think that a given item must always be a text list, but all it takes is someone writing sloppy code in an one-time fix-it agent and you could end up having a document in which that item is numeric!
Checking your fields is actually a good reason (sometimes) to encapsulate your field access in a function, much like the way you have attempted to do. The reason I added "sometimes" above is that your code's behavior for a missing field isn't necessarily always going to be the same, but for cases where you just want to return a default value when the field doesn't exist you can use something like this:
lsaddress ImsField("address","")
private function ImsField(fieldName,defaultValue)
if doc.hasItem(fieldName) then
lsaddress=doc.getItemValue(fieldName)(0)
else
lsaddress=defaultValue
end if
end function
Type mismatch comes,
When you try to set values from one kind of datatype variable to different datatype of another variable.
Eg:-
dim x as String
Dim z as variant
z= Split("Test:XXX",":")
x=z
The above will through the error what you mentioned.
So check the below code...
lsaddress = ImsField(doc.address)
What is the datatype of lsaddress?
What is the return type of ImsField(doc.address)?
If the above function parameter is a string, then you should pass the parameter like (doc.address(0))
I have added an extra field in the Pages table that I call VirtualPath. This is so that I can have virtual paths to my pages.
In the code I add "VirtualPath" as an extra parameter to the CommandText which means that there will be 14 elements to pick from the database. I duplicate the routine to grep the actual value:
if (!rdr.isDbNull(14))
{
page.VirtualPath = rdr.GetString(14);
}
The problem is that the it never enters the if-statement. When I step the code and I arrive at the !rdr.isDbNull(14)-row and do step-in I see that the DBHelper makes a dispose somehow...
My question is: Is there somewhere else I have to do a change to add an extra parameter like this? Or, does anyone have an idea of what I do wrong. And yes, I have entered values to the VirtualPath-field in the database so it should not be null.
If there are 14 elements to pick from the table, the 14th should be referenced by index 13 (zero-based index).