This is a migrated thread and some comments may be shown as answers.

Conditional filtering??

2 Answers 349 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Brian
Top achievements
Rank 1
Brian asked on 22 Feb 2016, 11:29 PM
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 Answers, 1 is accepted

Sort by
0
Brian
Top achievements
Rank 1
answered on 23 Feb 2016, 12:39 AM
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.
0
Stef
Telerik team
answered on 25 Feb 2016, 03:37 PM
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
Tags
General Discussions
Asked by
Brian
Top achievements
Rank 1
Answers by
Brian
Top achievements
Rank 1
Stef
Telerik team
Share this question
or