Hi,
How do you create a function that you can call inside the Query Explorer's Data Items.
For example, I want to create a function (never mind the syntax just yet)
function validDate (invoicedate)
var validDateFr, validDateTo
if (inRange(..))
return true
return false.
end function
So a Data Item's expression definition, I could have something like this:
if (validDate(current_date)) then
"OK"
else "NOT OK"
Possible to do?
TIA!
Most databases will allow you to create User Defined Functions (UDFs) that you can import into Cognos, and then use like any other function.
SQL Server:
https://docs.microsoft.com/en-us/sql/relational-databases/user-defined-functions/create-user-defined-functions-database-engine
Oracle:
https://docs.oracle.com/cd/B19306_01/server.102/b14200/functions231.htm
Once you create the function, you can use the import wizard in Framework Manager to import it. There should be an expandable functions list.
I see, so it's not as simple as I initially thought. :(
Thank you for taking the time to respond. I'll explore this option.
You may be able to do this with a Cognos macro, although the macro feature is pretty limited.
Are you sure you need a function? How about just a data item?
if ([invoicedate] between ?validDateFr? and ?validDateTo?)
then ('OK')
else ('Not OK')