Spotfire date expression error - spotfire

In spotfire I have a column property fromDate and toDate which is a Date. I am trying to limit the result of data using expression below. But I keep on encountering this error
Invalid type for function call 'DocumentProperty' on line1, character 19
Limit Expression
[poddate] >= Date(DocumentProperty(${DevInfoYTD}.{Location}.{fromDate})) and
[poddate] <= Date(DocumentProperty(${DevInfoYTD}.{Location}.{toDate}))
If I used the below expression i don't get an error but there is no data shown on the table.
[poddate] >= Date(${DevInfoYTD}.{Location}.{fromDate})
and [poddate] <= Date(${DevInfoYTD}.{Location}.{toDate})
Any ideas on how to fix it?

You don't need a three part identifier. I'm unsure of what that even is supposed to be, but you only need to list the property control.
[poddate] >= Date("${YourPropertyControlName}")
AND
and [poddate] <= Date("${YourOtherPropertyControlName}")

Related

Why I get error message "Invalid number" since UserID is NUMBER

I am little bit confusing and have no idea where I made mistake.
SELECT uta.StartDate, uta.EndDate FROM user_timesheets_absence uta
WHERE uta.UserID = 353
AND uta.Approved = 'true'
AND '2020-03-06' BETWEEN TO_DATE(uta.StartDate,'YYYY-MM-DD') AND TO_DATE(uta.EndDate,'YYYY-MM-DD') + INTERVAL '1' DAY
In following query I get error
ORA-01722: invalid number
I try to understand where the error is, but when I realize query a deeper I can not see where the error is.
ABSENCETYPE VARCHAR2(255 CHAR)
ANSWER VARCHAR2(500 CHAR)
APPROVED NUMBER(10,0)
COMMENT_ CLOB
DAYS NUMBER(10,0)
ENDDATE VARCHAR2(50 CHAR)
ISANSWERED NUMBER(10,0)
ISREJECTED NUMBER(10,0)
STARTDATE VARCHAR2(50 CHAR)
USERABSENCEID NUMBER(10,0)
USERHASSEEN VARCHAR2(500 CHAR)
USERID NUMBER(10,0)
WIDTH NUMBER(10,0)
When I insert data into table, I use this kind of data and It works fine. But when I use SELECT statment I get error. I hope the error was UserID but it wasn't.
Insert into DB.USER_TIMESHEETS_ABSENCE (ABSENCETYPE,ANSWER,APPROVED,DAYS,ENDDATE,ISANSWERED,ISREJECTED,STARTDATE,USERABSENCEID,USERHASSEEN,USERID,WIDTH) values ('1','ne',0,8,'2020-02-06',1,1,'2020-01-30',89,'1',348,160);
Can someone tell me, where I made mistake ? What is wrong here ?
There is more than one problem in this query.
Firstly, here:
AND uta.Approved = 'true'
approved is a number, but you are comparing it against string 'true'. This does not work. Use a literal number on the right side of the equal sign.
Then, here:
AND '2020-03-06'
BETWEEN TO_DATE(uta.StartDate,'YYYY-MM-DD')
AND TO_DATE(uta.EndDate,'YYYY-MM-DD') + INTERVAL '1' DAY
You are comparing a string against dates. This won't work. You probably want a literal date on the left side of between. I would also recommend using + 1 rather than the interval syntax, which should be reserved to timestamps:
AND DATE '2020-03-06'
BETWEEN TO_DATE(uta.StartDate,'YYYY-MM-DD')
AND TO_DATE(uta.EndDate,'YYYY-MM-DD') + 1
Why are STARTDATE and ENDDATE defined as strings rather than date. Not using the correct data types is a surefire way to introduce data corruption issues. That's certainly where I would start looking.
The other thing is, always use explicit casting when converting strings into dates (or numbers) and vice versa. In this case you should use a date literal. Instead of
AND '2020-03-06' BETWEEN TO_DATE(uta.StartDate,'YYYY-MM-DD') AND TO_DATE(uta.EndDate,'YYYY-MM-DD')
use
AND date '2020-03-06' BETWEEN TO_DATE(uta.StartDate,'YYYY-MM-DD') AND TO_DATE(uta.EndDate,'YYYY-MM-DD')
If you have got data corruption in your date columns and you're on 12c or later you can use VALIDATE_CONVERSATION to filter rows which don't contain valid dates:
SELECT uta.StartDate, uta.EndDate FROM user_timesheets_absence uta
WHERE uta.UserID = 353
AND uta.Approved = 'true'
AND validate_conversion(uta.StartDate,'YYYY-MM-DD') = 1
AND validate_conversion(uta.EndDate,'YYYY-MM-DD') = 1
AND date '2020-03-06' BETWEEN TO_DATE(uta.StartDate,'YYYY-MM-DD') AND TO_DATE(uta.EndDate,'YYYY-MM-DD') + INTERVAL '1' DAY
You can also use this to find invalid date strings:
SELECT *
FROM user_timesheets_absence uta
WHERE validate_conversion(uta.StartDate,'YYYY-MM-DD') = 0
OR validate_conversion(uta.EndDate,'YYYY-MM-DD') = 0

Query a range in an Excel table linked to PowerApps Text Search box

First time asking a question here. As well as being pretty new to PowerApps as well.
I am trying to use two text input boxes for the user to define the min & max of their number range. basically i want the code to return all results that fall in the user defined range.
User inputs are:
SearchText.Text
MinSearch.Text and
MaxSearch.Text
PDFData is the table, and
RMANumber is the column that i want the Min & Max to search and return all within the user defined range. as of now, all i can get this to return are exact results, which just won't work for my situation. In my way of thinking, i want to add WHERE after the RAWidth and give greater or lesser arguments, but this isn't working for me. My full code is below, and any help is appreciated.
If(SearchText.Text="" && MinSearch.Text="" && MaxSearch.Text="", PDFData, Filter(PDFData,SearchText.Text in PDFAuthor|| SearchText.Text in PDFName|| SearchText.Text in RMANumber|| MinSearch.Text in RAWidth))
You can use the following expression for your query:
Filter(
PDFData,
SearchText.Text in PDFAuthor || SearchText.Text in PDFName,
Coalesce(Value(MinSearch.Text), -1) <= RAWidth,
Coalesce(Value(MaxSearch.Text), 1000000000) >= RAWidth)
If the SearchText is empty, then the conditions SearchText.Text in PDFAuthor and SearchText.Text in PDFName will both be true anyway, so there's no need for the If at that point.
For the other conditions, we can use the functions Value / Coalesce to convert the text input to a number; if the user didn't enter anything (or entered an invalid number), then the function Value will return a blank value, and the Coalesce function will use the next value. I'm using here -1 for the minumum value and 1000000000 for the maximum - if the possible range of values in your RAWidth column is between those numbers then you're fine.

Incorrect data type for operator or #function time/date expected on lotusscript?

In lotusScript: I've used:
doc.DocDate = Format(document.get("DatePublished"),"mm/dd/yyyy") 'Rem return 08/22/2017
In formula: I've used for to get year:
#Year(DocDate)
But when i run the program i get the error : "incorrect data type for operator or #function time/date expected". How to fix it?
Get date value with
document.DatePublished(0)
or
document.GetItemValue("DatePublished")(0)
Then your field DocDate should be calculated properly.
#Year() expects a NotesDateTime value. DocDate is a String value though. You can change your formula to
#Year(#ToTime(DocDate))
and it will work if your language settings are set to US date format.

Cognos query calculation - how to obtain a null/blank value?

I have a query calculation that should throw me either a value (if conditions are met) or a blank/null value.
The code is in the following form:
if([attribute] > 3)
then ('value')
else ('')
At the moment the only way I could find to obtain the result is the use of '' (i.e. an empty character string), but this a value as well, so when I subsequently count the number of distinct values in another query I struggle to get the correct number (the empty string should be removed from the count, if found).
I can get the result with the following code:
if (attribute='') in ([first_query].[attribute]))
then (count(distinct(attribute)-1)
else (count(distinct(attribute))
How to avoid the double calculation in all later queries involving the count of attribute?
I use this Cognos function:
nullif(1, 1)
I found out that this can be managed using the case when function:
case
when ([attribute] > 3)
then ('value')
end
The difference is that case when doesn't need to have all the possible options for Handling data, and if it founds a case that is not in the list it just returns a blank cell.
Perfect for what I needed (and not as well documented on the web as the opposite case, i.e. dealing with null cases that should be zero).

Lotus Notes Script Error: Field count mismatch

In my Lotus Notes script, i do have this piece of logic as shown below. This is basically for two SELECT statements, followed by Fetch for each of the SELECT statement separately and the SELECT is for the same DB2 table with a variation in WHERE clause. The error i'm getting is for the second FETCH. The error i'm getting is ---> Field count mismatch error:
count = 0
If (srccon.Execute(selectstatement, fldLst1) = 0) Then
Goto GetNextDoc
End If
count = srccon.Fetch(fldLst1)
If ( count = 0 ) Then
Goto GetNextDoc
End If
The above cursor select and fetch does not give me any error.
The cursor down which is for the same DB2 table with a slight variation
in WHERE clause is causing the error:
count1 = 0
If (srccon.Execute(selectstatement1, fldLst) = 0) Then
Goto GetNextDoc
End If
count1 = srccon.Fetch(fldLst) ---> The error is pointing to this line
and the error is
I would appreciate any help in this regard. I would also thank the gentleman who
did excellent solution for my previous problem for current date minus 30 days.
With much thanks
I suspect it's because when you call Execute, you're reusing the same LCFieldList object from a previous call. Execute and Select statements append their list of result fields to the object you pass them, so you must pass them an empty fieldlist -- one you just created. Otherwise you get a combined fieldlist of all the fields in the result sets of multiple calls to Select or Execute.
You may find the LotusScript chapter of this Redbook useful.

Resources