Reputation: 687
I'm working on something right that should only show e.g. the fifth element of a dataset. So I made sure the dataset is sorted correctly (alphabetically on title) and then I use this piece of code to give each row an incremental number.
public counter As Integer = 0
Function SetNumber()
counter = counter + 1
return counter
end Function
So the data would look something like this:
1 | Africa
2 | America
3 | Antarctica
4 | Asia
5 | Europe
6 | Oceania
After that I go to the Row Visibility of my detail row and choose to hide/show the row based on an expression. The expression I'm currently using is:
=iif(Fields!Increment.Value = 5, False, True)
With this expression ALL of the tablix-rows are hidden. If I switch the 'False' and 'True' values like this:
=iif(Fields!Increment.Value = 5, True, False)
Only the fifth row is hidden and all the rest is visible.
Does anyone know why my expression doesn't work or how I can make this functionality work.
EDIT "Query that gets data":
<RSSharePointList xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<ListName>Continents</ListName>
<ViewFields>
<FieldRef Name="Title" />
</ViewFields>
<Query>
<OrderBy>
<FieldRef Name="Title" Ascending="True"/>
</OrderBy>
</Query>
</RSSharePointList>
To this query I added a calculated field called 'Increment' that uses following expression:
=Code.SetNumber()
Upvotes: 3
Views: 3012
Reputation: 687
Ok, I found the solution. Thanks to user2900970 I realised that I shouldn't try to show the one item but hide all the other.
So with this expression I only get the 1 item I wanted:
=IIf(RowNumber(Nothing) <> 5, True, False)
Upvotes: 1
Reputation: 761
You want to hide rows with Increment.Value higher then 5. Therefore use
=IIf(Fields!Increment.Value <= 5, False, True)
Easier would be to remove the calculated field and use RowNumber() instead.
=IIf(RowNumber(Nothing) <= 5, False, True)
Upvotes: 2