Conditional filtering??

3 posts, 0 answers
  1. Brian
    Brian avatar
    4 posts
    Member since:
    Jul 2013

    Posted 22 Feb 2016 Link to this post

    I am working on converting some Crystal Reports over to use Telerik Reporting, and I am stuck on writing a filter for my data. Basically, I have a parameter FacID that is able to be blank, and I will filter the data differently depending on that value. In addition to that, there is also filtering dependent on the value of another parameter ActiveOnly.

    Here is what it looked like in Crystal:

    IF {?FacID} = "" THEN (
        IF {?LabelType} = "M" THEN (
            {FacilityCustomFields.CFID} = 14 AND
            ({FacilityCustomFields.CFValue} = "Y" OR
                {FacilityCustomFields.CFValue} = "CYCLE") AND
            {FacilityCustomFields_1.CFID} = 13 AND
            IF {?ActiveOnly} THEN
                {Facilities.FacStatus} = "A"
            ELSE TRUE
        ) ELSE IF {?LabelType} = "X" THEN (
            {FacilityCustomFields.CFID} = 14 AND
            {FacilityCustomFields_1.CFID} = 13 AND
            IF {?ActiveOnly} THEN
                {Facilities.FacStatus} = "A"
            ELSE TRUE
        )
    ) ELSE
        IF {?LabelType} = "C" AND {?CycleGroup} <> "" THEN (
            {FacilityCustomFields.CFID} = 28 AND
            ({FacilityCustomFields.CFValue}[1] = "Y" OR
                {FacilityCustomFields.CFValue} = "PAPER") AND
            {FacilityCustomFields_1.CFID} = 13 AND
            {FacilityCustomFields_1.CFValue} = {?CycleGroup} AND
            IF {?ActiveOnly} THEN
                {Facilities.FacStatus} = "A"
            ELSE TRUE
        ) ELSE (
            {FacilityCustomFields.FacID} = {?FacID} AND
            {FacilityCustomFields.CFID} = 14 AND
            {FacilityCustomFields_1.CFID} = 13 AND
            IF {?ActiveOnly} THEN
                {Facilities.FacStatus} = "A"
            ELSE TRUE
        )
  2. Brian
    Brian avatar
    4 posts
    Member since:
    Jul 2013

    Posted 22 Feb 2016 in reply to Brian Link to this post

    What I ended up doing for now is work all of the filtering logic directly into the data source SELECT query. I find it much easier to work with SQL syntax than a bunch of nested IIf() statements in an expression. Hopefully some day Telerik will catch up to Crystal Reports in ease of use. Definitely a great reporting solution, but there are a few things that seem to be much more difficult than they should be.
  3. Stef
    Admin
    Stef avatar
    3610 posts

    Posted 25 Feb 2016 Link to this post

    Hello Brian,

    I am glad to hear you found a solution.

    For anyone interested, filtering can be applied on data-retrieval or on report level - Filtering Data.
    If the filer is applied on report level, you can use an expression to create more complex filter criteria including operators and compound terms. For example you can use the IIf conditional function and ?: operator. For example, a filter Expression like:
    =IIf( (Fields.val=10?'Yes':'No') = Parameters.Parameter1.Value,
              Null,'YesYes') Is Null
      AND 1=1
    You can format the expression in the 'Edit Expression' dialog for neatness


    I hope this information helps.

    Regards,
    Stef
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top