Sunday, February 19, 2012

Filtering Top n on Group or Table

Hopefully someone can help.

I am trying to filter either my group or the whole table to return the top 5 lines of my data.

If I use Topn (Fieldname) = 5 in my filter for the group, it returns merely the total of the table and hides all the detail.

If I use the same filter in the table filter, only the table header is returned.

I have rather a complex formula based on parameters to calculate the field I want to show the top 5 of. e.g. If parameter equals 2 then add balance_period_1 to balance_period_2. This formula works perfectly if I remove the top5 filter. See detailed expression below

The expression is

Topn(iif(Parameters!Period.Value = "02", Fields!Year_Opening_Balance. Value+Fields!Balance_Period_01.Value +Fields!Balance_Period_02.Value,0))

The Operator is set to =

The Value is set to 5

Any ideas would be greatly appreciated.

Set the filter expression to:
=iif(Parameters!Period.Value = "02", Fields!Year_Opening_Balance. Value+Fields!Balance_Period_01.Value +Fields!Balance_Period_02.Value,0))

Set the filter operator to:
TopN

Set the filter value to:
=5

Note: if you set the filter value to just 5, it will be interpreted as string constant - which won't work. You have to set it to =5, which will evaluate to the integer value 5.

-- Robert

|||

Thanks!!

So simple but blind to my eyes, now all is revealed!

No comments:

Post a Comment