Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

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

1 Solution

Accepted Solutions
sunny_talwar
MVP
MVP

My bad... once more change

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)

View solution in original post

13 Replies
swuehl
Champion III
Champion III

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)?

Not applicable
Author

Ya I made it single pair now.


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

sunny_talwar
MVP
MVP

How about this:

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)

Not applicable
Author

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

sunny_talwar
MVP
MVP

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

Not applicable
Author

Yes I tested it.  Its showing error in set modifier

sunny_talwar
MVP
MVP

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)

Not applicable
Author

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.

Capture.PNG

sunny_talwar
MVP
MVP

My bad... once more change

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)