Reputation: 9603
Hello I have following column in SSRS Report.
Column Name(Title)
Mehta, Natasha(18)----its Title+(count) value
Rodriguez, Lauren(19)
Harwood, Matt(19)
Lloyd, David(19)
I want to find Average(18+19+19+19/4) from above column in SSRS Report.How can i do?
Upvotes: 1
Views: 894
Reputation: 2844
Assuming the column is called 'Title', the following may work:
=SUM(CAST(LEFT(RIGHT([Title], 3), 2)) AS int) / COUNT([Title]) * 1.0
=Sum(CDbl(Left(Right(Fields!Title.Value, 3), 2))) / CDbl(Count(Fields!Title.Value))
If we use the first row of data (Mehta, Natasha(18)) as a test string to step through this, we get:
Right(Fields!Title.Value, 3)
, 2))) / CDbl(Count(Fields!Title.Value))
Left(Right(Fields!Title.Value, 3), 2)
, 2))) / CDbl(Count(Fields!Title.Value))
Left('18)'), 2)
, 2))) / CDbl(Count(Fields!Title.Value))CDbl(Left(Right(Fields!Title.Value, 3), 2))
) / CDbl(Count(Fields!Title.Value))
CDbl('18')
) / CDbl(Count(Fields!Title.Value))CAST()
function in SQL (which can perform the equivalent of CDbl()
) can be read about here.Sum(CDbl(Left(Right(Fields!Title.Value, 3), 2)))
/ CDbl(Count(Fields!Title.Value))
Sum(18.0, 19.0, 19.0, 19.0)
/ CDbl(Count(Fields!Title.Value))CDbl(Count(Fields!Title.Value))
CDbl(Count(Fields!Title.Value))
Sum(CDbl(Left(Right(Fields!Title.Value, 3), 2))) / CDbl(Count(Fields!Title.Value))
75 / 4.0
Upvotes: 1
Reputation: 527
I would have used SQL functions in the dataset query itself, in order to separate the numbers into an independent column. It righter to get the data properly into the report than fixing it inside.
Upvotes: 0