SSRS表中某列中特定十进制值的计数



我正在尝试获取特定年龄的人的总数。AgeInYears是十进制数。

我试过求和,每次都得到0

=SUM(IIF( Fields!AgeInYears.Value = 15, 1, 0 ) )

如果我计数,我得到68,这仍然是不正确的

=Count(IIF( Fields!AgeInYears.Value = 15, 1, 0 ) )

我不确定我与十进制的比较是否正确。当我在SQL中使用查询,然后对数据使用透视表时,我能够找到答案47(我使用excel比SSRS好得多(。但在SSRS中,我只能得到一个0或68值。

编辑我正在通过在查询中计算年龄

cast(cast(datediff(month, invl.ChildDateOfBirth, fp.enddate) as decimal) / 12 as decimal) as AgeInYears

这可能有关系吗?

当我试图计算年龄时,我无法解决SSRS给我的任何问题。

相反,我已将查询更新为

Select
cast(cast(datediff(month, invl.ChildDateOfBirth, fp.enddate) as decimal) / 12 as decimal) as AgeInYears
From Table
Where
cast(cast(datediff(month, invl.ChildDateOfBirth, fp.enddate) as decimal) / 12 as decimal) > 13 
and 
cast(cast(datediff(month, invl.ChildDateOfBirth, fp.enddate) as decimal) / 12 as decimal) as AgeInYears < 19

这样可以确保我的数据只包含我想要的年龄(14-18岁之间(。然后在SSRS表中,我在AgeInYears上创建了一个行组,并进行了一个简单的

=Count(Fields!AgeInYears.Value)

以获得每个年龄的正确计数。

最新更新