Qlik Community

Ask a Question

New to Qlik Sense

If you’re new to Qlik Sense, start with this Discussion Board and get up-to-speed quickly.

Announcements
Talk to Experts Tuesday, January 26th at 10AM EST: Qlik Sense. REGISTER NOW
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

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
MVP
MVP

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

Ya I made it single pair now.


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

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

<> 'and' doesn't work 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

Not applicable

Yes I tested it.  Its showing error in set modifier

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

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

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