计数字段水晶报表

时间:2018-07-31 03:31:28

标签: asp.net-mvc crystal-reports crystal-reports-2008 crystal-reports-2010

我对数据库有一些看法

在这里查看

select main.processId,
main.departmentname as DepartmentName,
dpaudit.DropdownlistName DdlAudit, 
main.PICForAudit,
main.DateOfAudit,
main.ReferenceDetail,
main.finding as Finding,
CASE dpfinding.DropdownlistName WHEN 'RFI' THEN 'X' ELSE '' END AS IsRFi,
CASE dpfinding.DropdownlistName WHEN 'Minor NC' THEN 'X' ELSE '' END AS IsMinor,
CASE dpfinding.DropdownlistName WHEN 'Major NC' THEN 'X' ELSE '' END AS IsMajor,
iird.description as Description,
CASE spdl.DropdownlistName WHEN 'High Priority' THEN 'X' ELSE '' END AS High,
CASE spdl.DropdownlistName WHEN 'Medium Priority' THEN 'X' ELSE '' END AS Medium,
CASE spdl.DropdownlistName WHEN 'Low Priority' THEN 'X' ELSE '' END AS Low,
bc.DropdownlistName as RootCause,
iird.CorrectiveActionPlan,
iird.picResponsibilityName,
iird.TargetDateCompletion,
pos.positionname as Position
from SheAuditMain main 
join IncidentInvestigationRecommendationDescription iird on main.ProcessId = iird.PIDSource
join SheProgramsDropdownlistMenu spdl on spdl.dropdownlistcode = iird.priority
join SheProgramsDropdownlistMenu dpaudit on main.TypeOfAudit = dpaudit.DropdownlistCode 
join SheProgramsDropdownlistMenu dpfinding on main.TypeOfFinding = dpfinding.DropdownlistCode 
join SheProgramsDropdownlistMenu bc on bc.dropdownlistcode = iird.basiccause
join vwusrposOs pos on iird.picResponsibility = pos.positionid

然后我想使用Crystal Report创建报告,以便报告看起来像这样

https://ibb.co/eq924T

我们可以看到优先级[L,M,H]的计数 不正确,

我为此做一些代码 首先,我从每个字段[L,M,H]中添加运行总计字段 然后我在公式中编写代码

“高”字段的公式字段示例,因为“低”和“ med”相同

Local numberVar i := 0;
Local numberVar TotalHigh := 0;

for i := 0 to {#RTotalHigh} - 1 do   <{#RTotalHigh} coming from running total
    (
    if ({VwCheckPrior.High} = 'X') then
        TotalHigh := TotalHigh + 1
    else 
        0 
     );
TotalHigh  

如何显示正确的计算?

[抱歉图片,我之前忘记了我的帐户]

1 个答案:

答案 0 :(得分:0)

我认为您应该在该情况下使用NULL而不是空字符串(''),因为当您使用空字符串时,它将被总计