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

 

News:

MetaManager - Administrative Tools for IBM Cognos
Pricing starting at $2,100
Download Now    Learn More

Main Menu

Index Function

Started by gartmin, 28 Feb 2007 04:21:41 PM

Previous topic - Next topic

gartmin

Does Cognos have an index function? I am building a report and only want to count records with a certain character value inside a long character field. In SAS I believe it looks like this...

index(var1, 'charactervalue') > 0

So when used, if the string 'charactervalue' is contained anywhere in the variable var1, I would get a return.

MFGF

Hi,

The function you are looking for is position().

In Cognos 8, your example would be:

position('charactervalue', [var1])

If the string 'charactervalue' is not contained within the var1 item, the result would be 0, otherwise it would be the starting character position of charactervalue within var1.

Best regards,

MF.
Meep!

mikewalker

The thing about the position() function is that it does _NOT_ allow a "starting from" value.

Does anyone know of a way around this in C8? Any similar functions or workarounds?
Eg

If the value for [Column1] is 'Part1;Part2;Part3', how can I selectively substring each different part out?

(I was hoping to use MSSQL's CHARINDEX function in C8, but it compains about this for some reason)

TIA
Michael

COGNOiSe administrator

Just add the missing function to FM and report processors.

mikewalker

I decided it was easier to create a view and use that instead!

Thanks for the tip though! :)

Cheers
Michael