Quantcast
Channel: SQL Server Reporting Services, Power View forum
Viewing all articles
Browse latest Browse all 10045

TOP N Tablix filter does not work

$
0
0

I have a dataset that returns Car information. The report has table tablix and I wanted to filter the dataset by car’s Make and then select only TOP 5 rows

Here are the steps I followed

1>    Create dataset using SQL query below

2>    Drag & Drop table and set the data source

3>    In Tablix properties select filter and add two filters:

  1.       First Filter
    1. i.     Expression: “Make
    2. ii.     Operator: IN
    3. iii.     Value: “Acura”,”BMW”
  2.      Second filter
    1. i.     Expression: “Make”
    2. ii.     Operator: TOP N
    3. iii.     Value: 5

The dataset has 2 Acura, and 5 BMW. So expected ouput should be 2 Acura & 3 BMW. but table always shows 5 BMW.

Not sure why? Below is SQL for dataset and .rld file

SELECT 'Acura' AS 'Make', 'TL' AS 'Model', 2014 AS 'Year' ,30000 AS 'Cost'
UNION
SELECT 'Acura' AS 'Make', 'TL' AS 'Model', 2013 AS 'Year' ,25000 AS 'Cost'
UNION
SELECT 'BMW' AS 'Make', '328' AS 'Model', 2014 AS 'Year' ,35000 AS 'Cost'
UNION
SELECT 'BMW' AS 'Make', '528' AS 'Model', 2013 AS 'Year' ,50000 AS 'Cost'
UNION
SELECT 'BMW' AS 'Make', 'Z4' AS 'Model', 2012 AS 'Year' ,40000 AS 'Cost'
UNION
SELECT 'BMW' AS 'Make', 'BMW i' AS 'Model', 2014 AS 'Year' ,120000 AS 'Cost'
UNION
SELECT 'BMW' AS 'Make', 'X3' AS 'Model', 2013 AS 'Year' ,40000 AS 'Cost'
UNION
SELECT 'Lexus' AS 'Make', 'ES 350' AS 'Model', 2013 AS 'Year' ,45000 AS 'Cost'
UNION
SELECT 'Lexus' AS 'Make', 'RX' AS 'Model', 2013 AS 'Year' ,50000 AS 'Cost'
UNION
SELECT 'Lexus' AS 'Make', 'CT' AS 'Model', 2014 AS 'Year' ,32000 AS 'Cost'
UNION
SELECT 'Ford' AS 'Make', 'F-150' AS 'Model', 2011 AS 'Year' ,25000 AS 'Cost'
UNION
SELECT 'Ford' AS 'Make', 'Escape' AS 'Model', 2012 AS 'Year' ,25000 AS 'Cost'
UNION
SELECT 'Fors' AS 'Make', 'Fusion' AS 'Model', 2013 AS 'Year' ,30000 AS 'Cost'
Order By 'Make','Model'

<?xml version="1.0" encoding="utf-8"?><Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner"><Body><ReportItems><Tablix Name="Tablix1"><TablixBody><TablixColumns><TablixColumn><Width>1in</Width></TablixColumn><TablixColumn><Width>1in</Width></TablixColumn><TablixColumn><Width>1in</Width></TablixColumn><TablixColumn><Width>1in</Width></TablixColumn></TablixColumns><TablixRows><TablixRow><Height>0.25in</Height><TablixCells><TablixCell><CellContents><Textbox Name="Textbox9"><CanGrow>true</CanGrow><KeepTogether>true</KeepTogether><Paragraphs><Paragraph><TextRuns><TextRun><Value>Make</Value><Style /></TextRun></TextRuns><Style /></Paragraph></Paragraphs><rd:DefaultName>Textbox9</rd:DefaultName><Style><Border><Color>LightGrey</Color><Style>Solid</Style></Border><PaddingLeft>2pt</PaddingLeft><PaddingRight>2pt</PaddingRight><PaddingTop>2pt</PaddingTop><PaddingBottom>2pt</PaddingBottom></Style></Textbox></CellContents></TablixCell><TablixCell><CellContents><Textbox Name="Textbox1"><CanGrow>true</CanGrow><KeepTogether>true</KeepTogether><Paragraphs><Paragraph><TextRuns><TextRun><Value>Model</Value><Style /></TextRun></TextRuns><Style /></Paragraph></Paragraphs><rd:DefaultName>Textbox1</rd:DefaultName><Style><Border><Color>LightGrey</Color><Style>Solid</Style></Border><PaddingLeft>2pt</PaddingLeft><PaddingRight>2pt</PaddingRight><PaddingTop>2pt</PaddingTop><PaddingBottom>2pt</PaddingBottom></Style></Textbox></CellContents></TablixCell><TablixCell><CellContents><Textbox Name="Textbox3"><CanGrow>true</CanGrow><KeepTogether>true</KeepTogether><Paragraphs><Paragraph><TextRuns><TextRun><Value>Year</Value><Style /></TextRun></TextRuns><Style /></Paragraph></Paragraphs><rd:DefaultName>Textbox3</rd:DefaultName><Style><Border><Color>LightGrey</Color><Style>Solid</Style></Border><PaddingLeft>2pt</PaddingLeft><PaddingRight>2pt</PaddingRight><PaddingTop>2pt</PaddingTop><PaddingBottom>2pt</PaddingBottom></Style></Textbox></CellContents></TablixCell><TablixCell><CellContents><Textbox Name="Textbox5"><CanGrow>true</CanGrow><KeepTogether>true</KeepTogether><Paragraphs><Paragraph><TextRuns><TextRun><Value>Cost</Value><Style /></TextRun></TextRuns><Style /></Paragraph></Paragraphs><rd:DefaultName>Textbox5</rd:DefaultName><Style><Border><Color>LightGrey</Color><Style>Solid</Style></Border><PaddingLeft>2pt</PaddingLeft><PaddingRight>2pt</PaddingRight><PaddingTop>2pt</PaddingTop><PaddingBottom>2pt</PaddingBottom></Style></Textbox></CellContents></TablixCell></TablixCells></TablixRow><TablixRow><Height>0.25in</Height><TablixCells><TablixCell><CellContents><Textbox Name="Make"><CanGrow>true</CanGrow><KeepTogether>true</KeepTogether><Paragraphs><Paragraph><TextRuns><TextRun><Value>=Fields!Make.Value</Value><Style /></TextRun></TextRuns><Style /></Paragraph></Paragraphs><rd:DefaultName>Make</rd:DefaultName><Style><Border><Color>LightGrey</Color><Style>Solid</Style></Border><PaddingLeft>2pt</PaddingLeft><PaddingRight>2pt</PaddingRight><PaddingTop>2pt</PaddingTop><PaddingBottom>2pt</PaddingBottom></Style></Textbox></CellContents></TablixCell><TablixCell><CellContents><Textbox Name="Model"><CanGrow>true</CanGrow><KeepTogether>true</KeepTogether><Paragraphs><Paragraph><TextRuns><TextRun><Value>=Fields!Model.Value</Value><Style /></TextRun></TextRuns><Style /></Paragraph></Paragraphs><rd:DefaultName>Model</rd:DefaultName><Style><Border><Color>LightGrey</Color><Style>Solid</Style></Border><PaddingLeft>2pt</PaddingLeft><PaddingRight>2pt</PaddingRight><PaddingTop>2pt</PaddingTop><PaddingBottom>2pt</PaddingBottom></Style></Textbox></CellContents></TablixCell><TablixCell><CellContents><Textbox Name="Year"><CanGrow>true</CanGrow><KeepTogether>true</KeepTogether><Paragraphs><Paragraph><TextRuns><TextRun><Value>=Fields!Year.Value</Value><Style /></TextRun></TextRuns><Style /></Paragraph></Paragraphs><rd:DefaultName>Year</rd:DefaultName><Style><Border><Color>LightGrey</Color><Style>Solid</Style></Border><PaddingLeft>2pt</PaddingLeft><PaddingRight>2pt</PaddingRight><PaddingTop>2pt</PaddingTop><PaddingBottom>2pt</PaddingBottom></Style></Textbox></CellContents></TablixCell><TablixCell><CellContents><Textbox Name="Cost"><CanGrow>true</CanGrow><KeepTogether>true</KeepTogether><Paragraphs><Paragraph><TextRuns><TextRun><Value>=Fields!Cost.Value</Value><Style /></TextRun></TextRuns><Style /></Paragraph></Paragraphs><rd:DefaultName>Cost</rd:DefaultName><Style><Border><Color>LightGrey</Color><Style>Solid</Style></Border><PaddingLeft>2pt</PaddingLeft><PaddingRight>2pt</PaddingRight><PaddingTop>2pt</PaddingTop><PaddingBottom>2pt</PaddingBottom></Style></Textbox></CellContents></TablixCell></TablixCells></TablixRow></TablixRows></TablixBody><TablixColumnHierarchy><TablixMembers><TablixMember /><TablixMember /><TablixMember /><TablixMember /></TablixMembers></TablixColumnHierarchy><TablixRowHierarchy><TablixMembers><TablixMember><KeepWithGroup>After</KeepWithGroup></TablixMember><TablixMember><Group Name="Details" /></TablixMember></TablixMembers></TablixRowHierarchy><DataSetName>DataSet1</DataSetName><Filters><Filter><FilterExpression>=Fields!Make.Value</FilterExpression><Operator>In</Operator><FilterValues><FilterValue>Acura</FilterValue><FilterValue>BMW</FilterValue></FilterValues></Filter><Filter><FilterExpression>=Fields!Make.Value</FilterExpression><Operator>TopN</Operator><FilterValues><FilterValue>5</FilterValue></FilterValues></Filter></Filters><Top>0.51958in</Top><Left>0.70708in</Left><Height>0.5in</Height><Width>4in</Width><Style><Border><Style>None</Style></Border></Style></Tablix></ReportItems><Height>2in</Height><Style /></Body><Width>6.5in</Width><Page><LeftMargin>1in</LeftMargin><RightMargin>1in</RightMargin><TopMargin>1in</TopMargin><BottomMargin>1in</BottomMargin><Style /></Page><AutoRefresh>0</AutoRefresh><DataSources><DataSource Name="DataSource1"><DataSourceReference>PropertyTax</DataSourceReference><rd:SecurityType>None</rd:SecurityType><rd:DataSourceID>9860a4cb-b3ae-4b41-a978-491ec46d23fd</rd:DataSourceID></DataSource></DataSources><DataSets><DataSet Name="DataSet1"><Query><DataSourceName>DataSource1</DataSourceName><CommandText>SELECT 'Acura' AS 'Make', 'TL' AS 'Model', 2014 AS 'Year' ,30000 AS 'Cost'
UNION
SELECT 'Acura' AS 'Make', 'TL' AS 'Model', 2013 AS 'Year' ,25000 AS 'Cost'
UNION
SELECT 'BMW' AS 'Make', '328' AS 'Model', 2014 AS 'Year' ,35000 AS 'Cost'
UNION
SELECT 'BMW' AS 'Make', '528' AS 'Model', 2013 AS 'Year' ,50000 AS 'Cost'
UNION
SELECT 'BMW' AS 'Make', 'Z4' AS 'Model', 2012 AS 'Year' ,40000 AS 'Cost'
UNION
SELECT 'BMW' AS 'Make', 'BMW i' AS 'Model', 2014 AS 'Year' ,120000 AS 'Cost'
UNION
SELECT 'BMW' AS 'Make', 'X3' AS 'Model', 2013 AS 'Year' ,40000 AS 'Cost'
UNION
SELECT 'Lexus' AS 'Make', 'ES 350' AS 'Model', 2013 AS 'Year' ,45000 AS 'Cost'
UNION
SELECT 'Lexus' AS 'Make', 'RX' AS 'Model', 2013 AS 'Year' ,50000 AS 'Cost'
UNION
SELECT 'Lexus' AS 'Make', 'CT' AS 'Model', 2014 AS 'Year' ,32000 AS 'Cost'
UNION
SELECT 'Ford' AS 'Make', 'F-150' AS 'Model', 2011 AS 'Year' ,25000 AS 'Cost'
UNION
SELECT 'Ford' AS 'Make', 'Escape' AS 'Model', 2012 AS 'Year' ,25000 AS 'Cost'
UNION
SELECT 'Fors' AS 'Make', 'Fusion' AS 'Model', 2013 AS 'Year' ,30000 AS 'Cost'
Order By 'Make','Model'</CommandText></Query><Fields><Field Name="Make"><DataField>Make</DataField><rd:TypeName>System.String</rd:TypeName></Field><Field Name="Model"><DataField>Model</DataField><rd:TypeName>System.String</rd:TypeName></Field><Field Name="Year"><DataField>Year</DataField><rd:TypeName>System.Int32</rd:TypeName></Field><Field Name="Cost"><DataField>Cost</DataField><rd:TypeName>System.Int32</rd:TypeName></Field></Fields></DataSet></DataSets><rd:ReportUnitType>Inch</rd:ReportUnitType><rd:ReportID>1de33983-2722-4607-bca4-6ff5576e8b9a</rd:ReportID></Report>


Viewing all articles
Browse latest Browse all 10045

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>