我在线与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)
在这段代码中,我检查了一些属性,如果它的值为true,我计算字段值。但是,如果某些值不存在(如果是current_is_activeValue.Value =&#34;&#34;),则在相应的单元格中将显示错误。 但错误必须不存在:必须显示必须为&#34;&#34;的Fields!current_duration.Value。看起来表达式无论如何都计算了两个IIF案例。 有人这样麻烦吗?
答案 0 :(得分:0)
试图打破你的表情来形象化Iffs:
第一个IIF的IF条件
=IIF(Fields!current_is_activeValue.Value = "True",
整个部分是第一个IIF的THEN条款。如您所见,所有三个值都被添加,因此将计算此子句中的两个IIF。
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,",",".")))
其他第一个IIF
,
Fields!current_duration.Value)
正在计算两个IIF。您可能需要编辑表达式。
答案 1 :(得分:0)