Previous/next ssrs 中的表达式翻译自 crystal 报告

Previous/next expression in ssrs translated from crystal reports

我得到了这个表达式:

=Switch(Fields!Kod.Value=1, "text",
Fields!Kod.Value=2, "text",
Fields!Kod.Value=3, "text",
Fields!Kod.Value=4, "text",
Previous(Fields!Kod.Value) = 4 and (Fields!Kod.Value = 5 or 
Fields!Kod.Value = 6 or fields!Kod.Value = 7 or 
fields!Kod.Value=8), "more text",
Fields!Kod.Value=5, "   text",
Fields!Kod.Value=6, "   text",
Fields!Kod.Value=7, "   text",
Fields!Kod.Value=8, "   text",
Fields!Kod.Value=9, "text")

这一行

 Previous(Fields!Kod.Value) = 4 and (Fields!Kod.Value = 5 or Fields!Kod.Value = 6 or fields!Kod.Value = 7 or fields!Kod.Value=8)

导致错误:

"The scope parameter must be set to a string constant that is equal to either the name of a containing group, the name of a containting data region, or the name of a dataset"

有问题的行是尝试翻译此 crystal 报告公式,该公式来自压制:

if {SP;1.Kod} = 4 and 
(next({SP;1.Kod})=5 or
next({SP;1.Kod})=6 or
next({SP;1.Kod})=7 or
next({SP;1.Kod})=8
)
 then false
else true

但我在想我可以将这两个公式放在一起并得到 "more text" 来显示 if previous(kod=4) And next(kod) = 5, 6, 7, 8.

如何使这个表达式起作用?还是我做错了?

您需要为之前的函数添加作用域。例如,这可能只是您的数据集名称(也可以是组名称等),如下所示。

PREVIOUS(Fields!Kod.Value, "dataset1")

注意:引号

好的,感谢这个网站 https://www.codykonior.com/2011/04/04/duh-moments-previous-and-cross-apply/ 和上面的艾伦回答 我们终于做到了!

他解释说,当行在一个组中时,它不知道从组中的哪个实例获取前一个。将 First() 添加到表达式中有效。

Previous(First(Fields!X.Value),"Group")

感谢评论中的帮助,希望这对某人有所帮助!