Search code examples
reporting-servicescrystal-reportsssrs-2012

Previous/next expression in ssrs translated from crystal reports


I got this expression:

=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")

This row

 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)

is resulting in an error:

"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"

The problematic row is a try of translating this crystal reports formula which is from a supress:

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

But I was thinking that I could put these two formulas together and get the "more text" to show if previous(kod=4) And next(kod) = 5, 6, 7, 8.

How can I make this expression work? Or am I doing this the wrong way?


Solution

  • Okay so thanks to this site https://www.codykonior.com/2011/04/04/duh-moments-previous-and-cross-apply/ and Alans answere above we finally did it!

    He explains that when the row is in a group it doesn't know which instance off the group to get the previous from. Adding First() to the expression worked.

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

    Thanks for the help in the comments and I hope this helpes someone!