13 Replies Latest reply: Mar 14, 2017 3:14 PM by Sunny Talwar

# AND /OR operations in set analysis

Hi,

I have to do and/or operations in set analysis . Code is following:

Count(

{<CurrYear_flag={'Y'} , Prev1Year_flag={'Y'}, Prev2Year_flag={'Y'}>}  +

{<CurrYear_flag={'Y'},Prev1Year_flag={'Y'},Prev2Year_flag -={'Y'}> }+

{<CurrYear_flag={'Y'},Prev1Year_flag -={'Y'},Prev2Year_flag={'Y'}>}

distinct ACCOUNT)

Can you please let me know right syntax to do this.  only first set {<CurrYear_flag={'Y'} , Prev1Year_flag={'Y'}, Prev2Year_flag={'Y'}>} is working. Rest 2 are giving 0 in results. Prev2Year_flag -={'Y'} is not working I try individually. It has data Y, - . I am looking for not 'Y' data. It is not working with Prev2Year_flag ={'-'} too

Thanks,

Akanksha

• ###### Re: AND /OR operations in set analysis

First, I think you should use only a single set expression (single pair of {} )

Count(

{<CurrYear_flag={'Y'} , Prev1Year_flag={'Y'}, Prev2Year_flag={'Y'}>  + <CurrYear_flag={'Y'},Prev1Year_flag={'Y'},Prev2Year_flag -={'Y'}> + <CurrYear_flag={'Y'},Prev1Year_flag -={'Y'},Prev2Year_flag={'Y'}>}

distinct ACCOUNT)

Not sure if the parts are ok. Do you maybe need to handle NULL (which may appear as '-' on different places)?

• ###### Re: AND /OR operations in set analysis

Ya I made it single pair now.

Can you please let me know in this case how will I check for null

• ###### Re: AND /OR operations in set analysis

Count({<ACCOUNT = {"=

(CurrYear_flag = 'Y' and Prev1Year_flag = 'Y', Prev2Year_flag = 'Y') or

(CurrYear_flag = 'Y' and Prev1Year_flag = 'Y' and Prev2Year_flag <> 'Y') or

(CurrYear_flag = 'Y' and Prev1Year_flag <> 'Y' and Prev2Year_flag <> 'Y')>}

DISTINCT ACCOUNT)

• ###### Re: AND /OR operations in set analysis

<> 'and' doesn't work in set analysis

• ###### Re: AND /OR operations in set analysis

Have you tested this or are you talking from experience? From what I know they both do work as a search string in set analysis

• ###### Re: AND /OR operations in set analysis

Yes I tested it.  Its showing error in set modifier

• ###### Re: AND /OR operations in set analysis

Missed a double quote and curly bracket at the end:

Count({<ACCOUNT = {"=

(CurrYear_flag = 'Y' and Prev1Year_flag = 'Y', Prev2Year_flag = 'Y') or

(CurrYear_flag = 'Y' and Prev1Year_flag = 'Y' and Prev2Year_flag <> 'Y') or

(CurrYear_flag = 'Y' and Prev1Year_flag <> 'Y' and Prev2Year_flag <> 'Y')"}>}

DISTINCT ACCOUNT)

• ###### Re: AND /OR operations in set analysis

Its giving 0 in result. I have pasted pic below. Seems like something wrong in brackets. last Closing bracket is not matching with red highlighted one's . Can you please check.

• ###### Re: AND /OR operations in set analysis

Count({<ACCOUNT = {"=

(CurrYear_flag = 'Y' and Prev1Year_flag = 'Y' and Prev2Year_flag = 'Y') or

(CurrYear_flag = 'Y' and Prev1Year_flag = 'Y' and Prev2Year_flag <> 'Y') or

(CurrYear_flag = 'Y' and Prev1Year_flag <> 'Y' and Prev2Year_flag <> 'Y')"}>}

DISTINCT ACCOUNT)

• ###### Re: AND /OR operations in set analysis

Awesome! its working now.

Can you please explain logic of " being used here

• ###### Re: AND /OR operations in set analysis

Logic of "?