Hi this is my test code
create table #tmp1 (matter_ref int null ,fee_earner varchar (10) null ,dateclosed datetime null ,value decimal null) insert into #tmp1 values ('12345','kerry','2013-12-10',9563.54) insert into #tmp1 values ('12345','kerry','2013-12-10',null) insert into #tmp1 values ('12345','kerry','2013-12-10',null) insert into #tmp1 values ('12345','kerry','2013-12-10',null) insert into #tmp1 values ('12345','kerry','2013-12-10',null) insert into #tmp1 values ('12345','kerry',null,null) insert into #tmp1 values ('23456','kerry',null,900.00) select matter_ref,fee_earner,dateclosed,value, row_number() over (partition by matter_ref order by value desc) as seq1 from #tmp1 drop table #tmp1
In SSRS I have set a matrix table with fee_earner in the row and value in the data section
To start I only want to bring back the value in the value column that meets this criteria
=IIF(not isnothing(Fields!dateclosed.Value) and Fields!seq1.Value = 1,Fields!value.Value,0)
this bring back the value 9564 which is the value I expect.
What I want to do is to average this value by how many records meet the above criteria which is one so the average would be 9564
but when using this =AVG(IIF(not isnothing(Fields!dateclosed.Value) and Fields!seq1.Value = 1,cint(Fields!value.Value),0)) I get 1366
It seems that it is averaging the 9564 by the 7 records.
How can I get around this?