COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: cognos74 on 28 Nov 2016 08:54:01 AM

Title: Position Filter Expresion
Post by: cognos74 on 28 Nov 2016 08:54:01 AM
Hi;

I have below example values in Recorded Value column in my query;
Individual;90
Group;120
Co-Treatment;30
Individual;90;60
Individual;Co-Treatment;60

In the report I have to get only below kind of records.  Can any one please let me know that how to get them in the report.
Individual;90;60
Individual;Co-Treatment;60
Title: Re: Position Filter Expresion
Post by: hespora on 29 Nov 2016 04:40:22 AM
Well you're giving us precious little here in order to understand what that data is and how we are to determine *why* those two records are the ones you want.

I'm guessing here that it's the fact that there are three segments to the values. Thus, we simply need to identify those rows containing 2 semicolons rather than one. That is done with

position(
  ';',
  substring(
    [value],
    position(
      ';',
      [value]
    ) +1
  )
)

> 0
Title: Re: Position Filter Expresion
Post by: cognos74 on 29 Nov 2016 08:30:26 AM
Thank you very much for your help hespora.  your code worked perfectly for me. 

just for clarification of your question: I need to find those records because someone did not entered the values properly in the database.
Title: Re: Position Filter Expresion
Post by: hespora on 29 Nov 2016 09:14:30 AM
you're very welcome; glad I could help!
Title: Re: Position Filter Expresion
Post by: cognos74 on 29 Nov 2016 12:40:49 PM
Hi hespora,

need little more help with your code.  I need to find below records also along with which rows contain 2 semicolons
(these records does not have semicolon and minutes they are bad records)
Group
Concurrent

please help me.
Title: Re: Position Filter Expresion
Post by: hespora on 30 Nov 2016 02:35:18 AM
That would be something like

(
position(
  ';',
  substring(
    [value],
    position(
      ';',
      [value]
    ) +1
  )
)

> 0
)

OR

(

position(
  ';',
  [value]
)

=0
)
Title: Re: Position Filter Expresion
Post by: cognos74 on 01 Dec 2016 01:50:23 PM
Hi hespora,

please let me know how to get only these records:

Individual;90
Group;120
Title: Re: Position Filter Expresion
Post by: hespora on 02 Dec 2016 02:50:42 AM
Ahem.... I would *assume* that out of trying to understand what the two solutions do that I've provided you before, you'd be able to build that yourself. I know I personally would have that expectation of myself rather than asking iterations of the same thing over and over. But that's just me. ;)

Anyways, records that have exactly one semicolon:


(
position(
  ';',
  [value]
)
>0
)
AND
(
position(
  ';',
  substring(
    [value],
    position(
      ';',
      [value]
    ) +1
  )
)

= 0
)