Showing posts with label filtering. Show all posts
Showing posts with label filtering. Show all posts

Wednesday, March 21, 2012

Dataset filtering... how?

Hi all,

I want to create a summary page for one of my report, depending on a
parameter, I would like to filter the dataset before creating the summary
fields.

I cannot figure out how to perform this filtering, my approach has been to
insert a Table control and map it to my dataset, then try and do some
filtering via the properties. When i then put something like

=sum(Fields!Sales.Value)

into the header (such that it is shown only once, not repeated), I get the
sum for the full dataset, not the filtered one.

Please help, is there any easier way todo this?

Lastly, I can't filter at the SQL level as the dataset is being used to
populate a chart below the summary.

Advice welcome.

Please help
Taz

Put the filter directly on the table (by opening the table properties dialog and selecting the filter tab).

Small sample report is attached at the bottom.

-- Robert

============================================================

<?xml version="1.0" encoding="utf-8"?>
<Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2005/01/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
<DataSources>
<DataSource Name="AdventureWorks">
<DataSourceReference>AdventureWorks</DataSourceReference>
<rd:DataSourceID>c2dc0e71-020b-48e3-9005-53286c923eb2</rd:DataSourceID>
</DataSource>
</DataSources>
<BottomMargin>1in</BottomMargin>
<RightMargin>1in</RightMargin>
<rd:DrawGrid>true</rd:DrawGrid>
<InteractiveWidth>8.5in</InteractiveWidth>
<rd:SnapToGrid>true</rd:SnapToGrid>
<Body>
<ReportItems>
<Table Name="table1">
<Footer>
<TableRows>
<TableRow>
<TableCells>
<TableCell>
<ReportItems>
<Textbox Name="textbox7">
<rd:DefaultName>textbox7</rd:DefaultName>
<ZIndex>3</ZIndex>
<Style>
<TextAlign>Right</TextAlign>
<PaddingLeft>2pt</PaddingLeft>
<PaddingBottom>2pt</PaddingBottom>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
</Style>
<CanGrow>true</CanGrow>
<Value>Sum</Value>
</Textbox>
</ReportItems>
</TableCell>
<TableCell>
<ReportItems>
<Textbox Name="value_1">
<rd:DefaultName>value_1</rd:DefaultName>
<ZIndex>2</ZIndex>
<Style>
<TextAlign>Right</TextAlign>
<PaddingLeft>2pt</PaddingLeft>
<PaddingBottom>2pt</PaddingBottom>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
</Style>
<CanGrow>true</CanGrow>
<Value>=Sum(Fields!value.Value)</Value>
</Textbox>
</ReportItems>
</TableCell>
</TableCells>
<Height>0.25in</Height>
</TableRow>
</TableRows>
</Footer>
<Filters>
<Filter>
<Operator>NotEqual</Operator>
<FilterValues>
<FilterValue>=2</FilterValue>
</FilterValues>
<FilterExpression>=Fields!id.Value</FilterExpression>
</Filter>
</Filters>
<DataSetName>DataSet1</DataSetName>
<Top>0.125in</Top>
<Width>4.33333in</Width>
<Details>
<TableRows>
<TableRow>
<TableCells>
<TableCell>
<ReportItems>
<Textbox Name="id">
<rd:DefaultName>id</rd:DefaultName>
<ZIndex>1</ZIndex>
<Style>
<TextAlign>Right</TextAlign>
<PaddingLeft>2pt</PaddingLeft>
<PaddingBottom>2pt</PaddingBottom>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
</Style>
<CanGrow>true</CanGrow>
<Value>=Fields!id.Value</Value>
</Textbox>
</ReportItems>
</TableCell>
<TableCell>
<ReportItems>
<Textbox Name="value">
<rd:DefaultName>value</rd:DefaultName>
<Style>
<TextAlign>Right</TextAlign>
<PaddingLeft>2pt</PaddingLeft>
<PaddingBottom>2pt</PaddingBottom>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
</Style>
<CanGrow>true</CanGrow>
<Value>=Fields!value.Value</Value>
</Textbox>
</ReportItems>
</TableCell>
</TableCells>
<Height>0.25in</Height>
</TableRow>
</TableRows>
</Details>
<Header>
<TableRows>
<TableRow>
<TableCells>
<TableCell>
<ReportItems>
<Textbox Name="textbox1">
<rd:DefaultName>textbox1</rd:DefaultName>
<ZIndex>5</ZIndex>
<Style>
<TextAlign>Right</TextAlign>
<PaddingLeft>2pt</PaddingLeft>
<PaddingBottom>2pt</PaddingBottom>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
</Style>
<CanGrow>true</CanGrow>
<Value>id</Value>
</Textbox>
</ReportItems>
</TableCell>
<TableCell>
<ReportItems>
<Textbox Name="textbox2">
<rd:DefaultName>textbox2</rd:DefaultName>
<ZIndex>4</ZIndex>
<Style>
<TextAlign>Right</TextAlign>
<PaddingLeft>2pt</PaddingLeft>
<PaddingBottom>2pt</PaddingBottom>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
</Style>
<CanGrow>true</CanGrow>
<Value>value</Value>
</Textbox>
</ReportItems>
</TableCell>
</TableCells>
<Height>0.25in</Height>
</TableRow>
</TableRows>
</Header>
<TableColumns>
<TableColumn>
<Width>2.16667in</Width>
</TableColumn>
<TableColumn>
<Width>2.16667in</Width>
</TableColumn>
</TableColumns>
<Height>0.75in</Height>
</Table>
</ReportItems>
<Height>1in</Height>
</Body>
<rd:ReportID>427ef1de-ff4a-42ab-96eb-9b4fbdc898e0</rd:ReportID>
<LeftMargin>1in</LeftMargin>
<DataSets>
<DataSet Name="DataSet1">
<Query>
<rd:UseGenericDesigner>true</rd:UseGenericDesigner>
<CommandText>select 1 as id, 5 as value union
select 2, 6 union
select 3, 7</CommandText>
<DataSourceName>AdventureWorks</DataSourceName>
</Query>
<Fields>
<Field Name="id">
<rd:TypeName>System.Int32</rd:TypeName>
<DataField>id</DataField>
</Field>
<Field Name="value">
<rd:TypeName>System.Int32</rd:TypeName>
<DataField>value</DataField>
</Field>
</Fields>
</DataSet>
</DataSets>
<Width>4.5in</Width>
<InteractiveHeight>11in</InteractiveHeight>
<Language>en-US</Language>
<TopMargin>1in</TopMargin>
</Report>

Dataset filtering... how?

Hi all,
I want to create a summary page for one of my report, depending on a
parameter, I would like to filter the dataset before creating the summary
fields.
I cannot figure out how to perform this filtering, my approach has been to
insert a Table control and map it to my dataset, then try and do some
filtering via the properties. When i then put something like
=sum(Fields!Sales.Value)
into the header (such that it is shown only once, not repeated), I get the
sum for the full dataset, not the filtered one.
Please help, is there any easier way todo this?
Lastly, I can't filter at the SQL level as the dataset is being used to
populate a chart below the summary.
Advice welcome.
Please help
TazIn the table properties you need to go to the Filter tab. You will then be
able to select the dataset field you want from the drop-down list and then
set what value(s) you want to include in the table.
HTH, Magendo_man
"Tarun Mistry" wrote:
> Hi all,
> I want to create a summary page for one of my report, depending on a
> parameter, I would like to filter the dataset before creating the summary
> fields.
> I cannot figure out how to perform this filtering, my approach has been to
> insert a Table control and map it to my dataset, then try and do some
> filtering via the properties. When i then put something like
> =sum(Fields!Sales.Value)
> into the header (such that it is shown only once, not repeated), I get the
> sum for the full dataset, not the filtered one.
> Please help, is there any easier way todo this?
> Lastly, I can't filter at the SQL level as the dataset is being used to
> populate a chart below the summary.
> Advice welcome.
> Please help
> Taz
>
>|||Thanks for ther reply.
I found that actually filtering directly on the dataset was my best option
(within the Data tab). My charts are working correctly on the condensed
data.
Taz
"magendo_man" <magendoman@.discussions.microsoft.com> wrote in message
news:C9DCDE28-059B-472C-BC4B-EDEC09C4E1B7@.microsoft.com...
> In the table properties you need to go to the Filter tab. You will then be
> able to select the dataset field you want from the drop-down list and then
> set what value(s) you want to include in the table.
> HTH, Magendo_man
> "Tarun Mistry" wrote:
>> Hi all,
>> I want to create a summary page for one of my report, depending on a
>> parameter, I would like to filter the dataset before creating the summary
>> fields.
>> I cannot figure out how to perform this filtering, my approach has been
>> to
>> insert a Table control and map it to my dataset, then try and do some
>> filtering via the properties. When i then put something like
>> =sum(Fields!Sales.Value)
>> into the header (such that it is shown only once, not repeated), I get
>> the
>> sum for the full dataset, not the filtered one.
>> Please help, is there any easier way todo this?
>> Lastly, I can't filter at the SQL level as the dataset is being used to
>> populate a chart below the summary.
>> Advice welcome.
>> Please help
>> Taz
>>

Dataset Filtering with multiple expressions

I would like to know how to dynamically change the And/Or value on the Filter tab within a dataset.

Here are my two expressions within the filter:

Code Snippet

=Switch(Parameters!TotalCostFilterOp.Value = "=",Fields!tcost.Value = Parameters!TotalCost.Value,Parameters!TotalCostFilterOp.Value = ">",Fields!tcost.Value > Parameters!TotalCost.Value,Parameters!TotalCostFilterOp.Value = ">=",Fields!tcost.Value >= Parameters!TotalCost.Value,Parameters!TotalCostFilterOp.Value = "between",Fields!tcost.Value >= Parameters!TotalCost.Value AND Fields!tcost.Value <= Parameters!TotalCost2.Value,Parameters!TotalCostFilterOp.Value = "ie", ISNothing(Fields!tcost.Value), Parameters!TotalCostFilterOp.Value= "<",Fields!tcost.Value < Parameters!TotalCost.Value,Parameters!TotalCostFilterOp.Value = "<=",Fields!tcost.Value <= Parameters!TotalCost.Value,Parameters!TotalCostFilterOp.Value = "<>",Fields!tcost.Value <> Parameters!TotalCost.Value)

Code Snippet

=Switch(Parameters!CompanyFilterOp.Value = "%",LCASE(Fields!company.Value) like "*" & LCASE(Parameters!Company.Value) & "*", Parameters!CompanyFilterOp.Value = "=",Fields!company.Value = Parameters!Company.Value, Parameters!CompanyFilterOp.Value = "ie", ISNothing(Fields!company.Value), Parameters!CompanyFilterOp.Value = "?", LCASE(Fields!company.Value) LIKE LCASE(Parameters!Company.Value), Parameters!CompanyFilterOp.Value = "<>", Fields!company.Value <> Parameters!Company.Value, Parameters!CompanyFilterOp.Value = "?%", LCASE(Fields!company.Value) LIKE LCASE(Parameters!Company.Value) & "*")

The operator for both these is set to "=", and the value is set to "=true".

Based on user selection in a report wizard, the 4th column (And/Or) may need to be changed from 'and' to 'or', or vice-versa.

Is there anyway to accomplish this programatically?

Thanks in advance for you help!

James Dean wrote:

I would like to know how to dynamically change the And/Or value on the Filter tab within a dataset.

Based on user selection in a report wizard, the 4th column (And/Or) may need to be changed from 'and' to 'or', or vice-versa.

Is there anyway to accomplish this programatically?

Hi,

If you look at the rdl code you would see how it is, i.e. for a OR you would see

<Filters>

<Filter>

<Operator>In</Operator>

<FilterValues>

<FilterValue>Test</FilterValue>

<FilterValue>Test2</FilterValue>

</FilterValues>

<FilterExpression>=Fields!Testnull.Value</FilterExpression>

</Filter>

</Filters>

Someone else in this forum may be able to show you the way to programatically alter the RDL however I am not sure that you have time to do this.

Could not you use a stored procedure instead?

Data filters makes creation of data driven subscriptions easier, however for direct use, it will have to pull all the data before applying the filter and as you know filters have limitations.

Philippe

|||

No I cannot use a stored procedure to do the filtering, because the users are using a wizard to select which parameters they want to use and how they want to apply it to the data. So the dataset is created with a stored proc that gets all the data, and filters on the report are used to change the data based on the user's choices.

Thanks.

Dataset Filtering Not Working

I am trying to filter data at the dataset level after it is returned.

However, the filters tab on in the Dataset window does not appear to work correctly.

I have tried the following expressions:

Expression Operator Value

=(Fields!IdLog.Value = Parameters!Id_Log.Value) = =True

=Fields!IdLog.Value = =Parameters!Id_Log.Value

When I rerun my dataset query, the entire dataset is returned, instead of the filtered dataset. This same behavior occurs if I try to run the report itself.

I do not understand why the filtering does not occur.

Any help would be greatly appreciated.

To get maximum performance with filtering its the best to build the parameter into the SQL-Query:

="select your_colums from your_table where ID='" & Parameters!Id_Log.Value & "'"

I never tried something different, because its waste of resources to retrieve 1000records from a database and filter out 999 of them..

|||

BenniG,

Thank you for your comment. However, I am try to filter the results that are returned from a Web Service, and therefore, I cannot specify the SQL Statement used to query the database.

|||

I tried the filter-tab:

=Fields!ID.Value = =Parameters!ID.Value

works if both fields have the same datatype, if one is a string and one an integer I get an error.. Maybe you have to change the datatype for the Parameter?
I think the filter has no effect on the !-Icon in datasets, but in my case it worked in preview mode..