How to filter using variable
-
- Posts: 62
- Joined: Mon Dec 11, 2006 1:43 pm
- Location: U.S.A.
How to filter using variable
I want my data band to filter on the field "Incident.Category" = variable.
On the Dictionary pane, I right clicked on Data Sources and chose "New Variable."
I entered a variable with a Name of MyCategory, Type of string and Default Value of Software.
Then I went to my DataBand and added a filter. I chose Expression and then used the expression builder to build:
Incident.Category = {MyCategory}
I also tried:
{Incident.Category} = {MyCategory}
When I preview in the designer, I see all of my records (it ignores my filter request). When I run the preview control, I get an exception saying that a ; is missing. I also tried adding a semi-colon (;) on the end, but I still get the same error.
What am I missing?
On the Dictionary pane, I right clicked on Data Sources and chose "New Variable."
I entered a variable with a Name of MyCategory, Type of string and Default Value of Software.
Then I went to my DataBand and added a filter. I chose Expression and then used the expression builder to build:
Incident.Category = {MyCategory}
I also tried:
{Incident.Category} = {MyCategory}
When I preview in the designer, I see all of my records (it ignores my filter request). When I run the preview control, I get an exception saying that a ; is missing. I also tried adding a semi-colon (;) on the end, but I still get the same error.
What am I missing?
How to filter using variable
Change Field is to expression, after then in expression field type:
C#
VB.Net
Thank you.
C#
Code: Select all
Incident.Category == MyCategory
Code: Select all
Incident.Category = MyCategory
-
- Posts: 62
- Joined: Mon Dec 11, 2006 1:43 pm
- Location: U.S.A.
How to filter using variable
Thanks. One more parameter question, is there a way to set a report parameter so it will allow all of the values in the report.
For example, sometimes I want to display "Open" items, sometimes I want to display "Closed" items and sometimes I want to display all items.
For example, sometimes I want to display "Open" items, sometimes I want to display "Closed" items and sometimes I want to display all items.
How to filter using variable
Please provide us with more details about the parameters you want to show or to hide.
What parameters from Dictionary do you want to hide? Did you mean only a filter expression?
Thank you.
What parameters from Dictionary do you want to hide? Did you mean only a filter expression?
Thank you.
How to filter using variable
Hi Sandy,
Not sure if this helps but if you want to see all values in the report you can disable the Filter on the DataBand by setting the Property FilterOn to false. When you do want to filter by a particular item ("Open", "Closed", etc) you can set the FilterOn Property to true;
Not sure if this helps but if you want to see all values in the report you can disable the Filter on the DataBand by setting the Property FilterOn to false. When you do want to filter by a particular item ("Open", "Closed", etc) you can set the FilterOn Property to true;
How to filter using variable
You can achieve your goal in the following ways:Sandy wrote:I would like to, for example, be able to have 3 report parameters, but allow the user to choose "All" for 1 of them and have that filter not apply (or that filter return all values). Thanks
1. In the filter dialog window of the DataBand you should choose in the Field is combobox an Expression value and to type the following expression there: MyVariable1
MyVariable1 - it is the bool type variable that is defined in the report Dictionary.
Important: ReadOnly checkbox must be checked and the Function checkbox also must be checked when you defining the variable.
The expression of the variable (or in the expression directly of the filter) should be set like this:
(CheckBoxControl1.Checked && (Customers.ContactTitle == "Owner")) ||
(CheckBoxControl2.Checked && (Customers.ContactTitle == "Sales Agent"))
2. Set the following to the BeforePrint event handler of the DataBand:
DataBand.Enabled = MyVariable1; (any expression of the bool type.)
Thank you.