If you are unable to create a new account, please email support@bspsoftware.com

 

How to add an calculated field in a query that works like an ID or Autonumber

Started by PeterDD, 20 Aug 2019 06:00:41 AM

Previous topic - Next topic

PeterDD

Hello, I've created a datamodule from a package in Cognos 11.

The data collected from a table does not have an ID field so I want to create the ID field manually.

is it possible to make a calculated field that generates an unique number for each row in the query?
:-\

oscarca

You could create a row counter data item e.g. running-total([Data Item]) which gives you a number för each row.
You can also create a layout calculation using the RowNumber() function.


oscarca

Or you could create a data item that creates a specific number depending on the value/string of a certain column:
case
when [Data item] = 'Car' then 1
when [Data item] = 'Train' then 2
when [Data item] = 'Boat' then 3
else null
end

No problem  :)

bus_pass_man

Is it possible that the keys in your query subject were hidden in the package?  If you need to use them, change the package to expose them.   

It is possible that the techniques above could produce results which could vary over time.