Not In Filter expression

Saqib Mahmood 1 Reputation point
2020-09-09T16:46:08.48+00:00

Hi,
I'm trying to filter my dataset rows where I dont want my dataset to have rows with X,P
I m not able to find "Not in" operator to filter the dataset based on ResultType field

How would I do that?

23571-image.png

SQL Server Reporting Services
SQL Server Reporting Services
A SQL Server technology that supports the creation, management, and delivery of both traditional, paper-oriented reports and interactive, web-based reports.
3,061 questions
0 comments No comments
{count} votes

7 answers

Sort by: Most helpful
  1. DJAdan 671 Reputation points
    2020-09-11T20:59:43.033+00:00

    HI Saqib,

    Try the following by replacing Expression, Operator, and Value with the code snippet below. I am not sure how you want to handle the case where ResultType is neither, X, P, or NULL, so I treat it like NULL.

    I hope this helps.

    --Dan

    Expression:

    =Switch
     (
     Fields!ResultType.Value = "X", "Exclude",
     Fields!ResultType.Value = "P", "Exclude",
     IsNothing(Fields!ResultType.Value) = "Include",
     True, "Include"
     )
    

    Operator: =
    Value: Include

    1 person found this answer helpful.
    0 comments No comments

  2. Joyzhao-MSFT 15,631 Reputation points
    2020-09-14T05:39:23.857+00:00

    Hi @Saqib Mahmood ,
    If we can not change the query, the most easy way for this scene would be adding another filter . Using two <> filter will resolve this . And we don't need to specify for NULL, it will be included if it exists in the dataset query result. See :
    24168-01.jpg
    Regards,
    Joy


    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.
    0 comments No comments

  3. Joyzhao-MSFT 15,631 Reputation points
    2020-09-10T02:29:21.44+00:00

    Hi @Saqib Mahmood
    For this you could either change the datasete query, add where clause :

    SELECT *  
    FROM table_name  
    WHERE  ResultType NOT IN (X,P)  
    

    Or you could in the report design tablix add visibility control , using expression as follow to hide those rows:

    =IIF(Fields!ResultType.value="X" or Fields!ResultType.value="P" ,TRUE, FALSE )  
    

    Best Regards,
    Joy


    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  4. Saqib Mahmood 1 Reputation point
    2020-09-10T13:57:13.25+00:00

    Hi @Joyzhao-MSFT ,

    Forgot to mention that I also need values with ResultType with null. So basically:

    I need: (ResultType <> X and ResultType <> Y) or ResultType is null

    0 comments No comments

  5. Joyzhao-MSFT 15,631 Reputation points
    2020-09-11T05:42:12.287+00:00

    Hi @Saqib Mahmood ,

    I think this query is suitable for your requirement, in this case we don't need to explicitly code for "OR ResultType IS NULL". It would be include in the result :

     SELECT *  
     FROM table_name  
     WHERE  ResultType NOT IN (X,P)  
    

    Regards,
    Joy


    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.