计数字段 Crystal 报表

Count Field Crystal Report

我有一些来自数据库的视图

这里是风景

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 报告创建报告,因此报告看起来像这样

https://ibb.co/eq924T

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

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

中编写代码

高字段的公式字段示例,因为低和中值相同

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  

如何显示正确的计算结果?

[对不起图片,我忘记了我之前的帐户]

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