Link to home
Start Free TrialLog in
Avatar of lentzi
lentzi

asked on

Top N filter for an MDX DataSet in Reporting Services

Reporting Services: Can you please tell me how do I use the filter option from the DataSource tab in order to retrieve the top N records from the dataset.

I tried several ways, see below, none of them work, I keep getting the error that "cannot evaluate filterx expression/filter values".

<DataSets>
    <DataSet Name="FoodMart_2000">
      <Fields>
        <Field Name="Category_Category_Description">
          <DataField>[Category].[Category Description].[MEMBER_CAPTION]</DataField>
          <rd:TypeName>System.String</rd:TypeName>
        </Field>
        <Field Name="Measures_Amount">
          <DataField>[Measures].[Amount]</DataField>
        </Field>
      </Fields>
      <Filters>
        <Filter>
          <FilterExpression>=RowNumber()</FilterExpression>
          <Operator>TopN</Operator>
          <FilterValues>
            <FilterValue>2</FilterValue>
          </FilterValues>
        </Filter>
      </Filters>
      <Query>
        <DataSourceName>FoodMart 2000</DataSourceName>
        <CommandText>select
{[Measures].[Amount]} on columns,
{[Category].[Category Description].Members} on rows
FROM
Budget</CommandText>
      </Query>
    </DataSet>

or with:

       <Filter>
          <FilterExpression>=Fields!Category_Category_Description.Value</FilterExpression>
          <Operator>TopN</Operator>
          <FilterValues>
            <FilterValue>2</FilterValue>
          </FilterValues>
        </Filter>

Avatar of lentzi
lentzi

ASKER

Found the answer on Microsoft's forum, but I will leave it here for the others:
<Filter>
          <FilterExpression>=Fields!Category_Category_Description.Value</FilterExpression>
          <Operator>TopN</Operator>
          <FilterValues>
            <FilterValue>=2</FilterValue>
          </FilterValues>
        </Filter>
ASKER CERTIFIED SOLUTION
Avatar of DarthMod
DarthMod
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial