【发布时间】:2016-03-18 14:40:48
【问题描述】:
我使用在线 CRM。这就是我使用 fetchXML 的原因。这是我的收获:
`<fetch aggregate="true" distinct="false" no-lock="false" mapping="logical">
<entity name="lead" >
<attribute name="fullname" alias="lead_name" groupby="true" />
<attribute name="new_bpf_stage" alias="lead_stage" groupby="true" />
<attribute name="new_substep" alias="lead_substep" groupby="true" />
<attribute name="leadid" alias="lead_id" groupby="true" />
<filter type="and" >
<condition attribute="createdon" operator="ge" value="@PeriodBeginning" />
<condition attribute="createdon" operator="le" value="@PeriodEnding" />
</filter>
<link-entity name="new_duration_life_cycle" from="new_lead_duration_life_cycleid" to="leadid" link-type="outer" >
<attribute name="new_duration" alias="current_duration" groupby="true" />
<attribute name="new_active" alias="current_is_active" groupby="true" />
<attribute name="new_transition_date" alias="current_transition_date" aggregate="max" />
<filter type="and" >
<condition attribute="new_active" operator="eq" value="1" />
</filter>
</link-entity>
<link-entity name="new_duration_life_cycle" from="new_lead_duration_life_cycleid" to="leadid" link-type="outer">
<attribute name="new_duration" alias="duration_sum" aggregate="sum" />
</link-entity>
</entity>
` 这是表达式代码:
=IIF(Fields!current_is_activeValue.Value = "True",
DATEDIFF ("d", CDate(Format(Fields!current_transition_dateValue.Value, "MM.dd.yyyy hh:mm:ss")), Now()) +
IIF(DATEDIFF ("h", CDate(Format(Fields!current_transition_dateValue.Value, "MM.dd.yyyy hh:mm:ss")), Now()) Mod 24 > 8,
8,
(DATEDIFF ("h", CDate(Format(Fields!current_transition_dateValue.Value, "MM.dd.yyyy hh:mm:ss")), Now())) Mod 24)/8 +
IIF(Fields!current_duration.Value = "",
0,
CDbl(Replace(Fields!current_duration.Value,",",".")))
,
Fields!current_duration.Value)
在这段代码中,我检查了一些属性,如果它的值为真,我计算字段值。但如果某些值不存在(如果 current_is_activeValue.Value = ""),则在相应的单元格中会显示错误。 但错误不得存在:必须显示 Fields!current_duration.Value 必须为“”。看起来表达式无论如何都会计算两种 IIF 情况。 有没有人遇到这样的问题?
【问题讨论】:
-
"d"和"h"在 SSRS 中无效DATEDIFF间隔,您可以使用DAY和HOUR或DateInterval.Day和DateInterval.Hour。请参阅文档here。另外,我不确定格式字符串中的句点是否允许。您可能需要将"MM.dd.yyyy hh:mm:ss"更改为"MM/dd/yyyy hh:mm:ss"或"MM-dd-yyyy hh:mm:ss"。
标签: reporting-services fetchxml ssrs-expression