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

Matching square brackets

Started by cenario, 15 Apr 2020 03:43:01 AM

Previous topic - Next topic

cenario

I'm trying to construct an expression to match a string with a format like this for example : "[00]"

My expression is:
IF (<variable> LIKE '%[__]%') THEN ('TRUE') ELSE ('FALSE')

However this always returns "False". Idk why but it has to do with the square brackets..

How do you type in the square brackets in cognos?

Thanks

Edit;
I noticed that if i use "<variable> LIKE '__]%'" then cognos recognizes the string.
So, the problem is on the first square bracket.. Does it need an escape character perhaps?

bus_pass_man

How many underscores are you using?  Are there values which have the square brackets separated by exactly those number of characters? Would a '%[%]%' be more appropriate?

It works for me.

I created a calculation  which looks for this pattern and then substitute a string where the opening and closing square brackets are used.

(COUNTRY_EN  like '%t___i%') There are 3 underscores  This will return Australia and substitute  Aus[ral]a

I then created a filter similar to this

C_Country_En   like '%[___]%' 
as you can see, it finds Aus[ral]a


'%t___i%' (3 underscores) will find Australia.
'%t_i%' (1 underscore) will find Austria but not Australia

'%t%i%' will find both Austria and Australia

cenario

#2
I already tried '%[%]%' and still no results..

However if i do '%]%' then i have my expected results.

Which leads me to think -> Cognos isn't recognizing the first open bracket.

I think i'm going crazy because the string i'm searching for is "[51]". There's no reason for Cognos not recognize the first bracket.. But somehow it doesn't..

Thanks anyway

edit. typo

edit2. I'm officially losing my mind.

'%[51]%' finds the string, but '%[%]%' does not.

bus_pass_man


bus_pass_man

You can't put more than one file in a post so I had to add this here.

MFGF

Good work sir!!

I'm wondering if this has anything to do with the underlying data source and reserved characters? It seems strange that it works for one person but not another.

Since this is a report, I'd also be looking closely at the SQL that gets generated, to see if the filter is being passed to the data source, and exactly how it is being formed if so.

Good luck!

MF.
Meep!