Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 12»»

Converting Crystal Report Formula(if condition) to SSRS Expand / Collapse
Author
Message
Posted Thursday, February 12, 2009 12:11 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Tuesday, April 09, 2013 11:20 AM
Points: 135, Visits: 247
Hi,
Currently I am migrating Crystal reports to SSRS 2008. I am struggling to covert Crystal rpt formulas like below to SSRS. if {table.Subject Parent ID} in [1005,1458, 1031, 1038, 1045, 1051,
1068, 1077, 1237, 1466, 1467, 1327, 1332, 1328,1001, 1295, 1296]
Or
{table.Seq.Subject} in [1005,1458, 1031, 1038, 1045, 1051,
1068, 1077, 1471, 1466, 1467, 1327, 1332, 1328,1001, 1002,1003,1295,1296]
then "Business Applications"

else If
{table.Subject Parent ID} = 1057 or {table.Seq.Subject} in [1478,1057]
then "Instructional Applications"


My question is, how to convert this to SSRS Expression. ( any nice way?) Help me...

Regards
Dhans
Post #656001
Posted Friday, February 13, 2009 10:33 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Tuesday, April 09, 2013 11:20 AM
Points: 135, Visits: 247
I did like below...

if (S_PID = 1005) or (S_PID = 1458) or (S_PID = 1031) or (S_PID = 1038) or (S_PID = 1045) or (S_PID = 1051) or (S_PID = 1068) or (S_PID = 1077) or _
(S_PID = 1471) or (S_PID = 1077) or (S_PID = 1466) or (S_PID = 1467) or (S_PID = 1327) or (S_PID = 1332) or (S_PID = 1328) or (S_PID = 1001) or _
(S_PID = 1295) or (S_PID = 1296) Or _
(Subject = 1005) or (Subject = 1458) or (Subject = 1031) or (Subject = 1038) or (Subject = 1045) or (Subject = 1051) or _
(Subject = 1068) or (Subject = 1077) or (Subject = 1471) or (Subject = 1077) or (Subject = 1466) or (Subject = 1467) or (Subject = 1327) or (Subject = 1332) _
or (Subject = 1328) or (Subject = 1001) or (Subject = 1002) or (Subject = 1003) or (Subject = 1295) or (Subject = 1296) then

IncidentAppType = "Business Applications"

Else If (S_PID = 1057) or (Subject = 1478) or (Subject = 1057) then
IncidentAppType = "Instructional Applications"
End If


Let me know is there any other logic around this in SSRS.
-----
Dhans
Post #656808
Posted Friday, February 13, 2009 10:25 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Saturday, February 23, 2013 2:58 AM
Points: 27, Visits: 393
Dhans (2/12/2009)
Hi,
Currently I am migrating Crystal reports to SSRS 2008. I am struggling to covert Crystal rpt formulas like below to SSRS. if {table.Subject Parent ID} in [1005,1458, 1031, 1038, 1045, 1051,
1068, 1077, 1237, 1466, 1467, 1327, 1332, 1328,1001, 1295, 1296]
Or
{table.Seq.Subject} in [1005,1458, 1031, 1038, 1045, 1051,
1068, 1077, 1471, 1466, 1467, 1327, 1332, 1328,1001, 1002,1003,1295,1296]
then "Business Applications"

else If
{table.Subject Parent ID} = 1057 or {table.Seq.Subject} in [1478,1057]
then "Instructional Applications"


My question is, how to convert this to SSRS Expression. ( any nice way?) Help me...

Regards
Dhans


I assume they are using this for a grouping purpose??
have you try using WHEN....THEN.... for example
WHEN Subject Parent ID IN ('111','112'..) THEN 'Business Applications'
ELSE 'Instructional Applications'
END AS TEMP

Have a read BOL of the correct syntax because my one might be wrong.
Post #657111
Posted Tuesday, February 24, 2009 2:00 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Tuesday, April 09, 2013 11:20 AM
Points: 135, Visits: 247
Thanks Sun.
I created a Calculated field in dataset and calling a function in Code behind. This function returns the Type of Incident.
Let me try with SQL Query it self.(using CASE... WHEN). This option may improve the performance too.
Dhans.
Post #663819
Posted Wednesday, February 25, 2009 8:28 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Friday, June 04, 2010 10:17 AM
Points: 191, Visits: 386
working it out at the SQL DB end is ideal. If that is not possible, then expression below should work.

=switch(S_PID = 1005 or S_PID = 1458 or S_PID = 1031 or S_PID = 1038 or S_PID = 1045 or S_PID = 1051 or S_PID = 1068 or S_PID = 1077 or
S_PID = 1471 or S_PID = 1077 or S_PID = 1466 or S_PID = 1467 or S_PID = 1327 or S_PID = 1332 or S_PID = 1328 or S_PID = 1001 or
S_PID = 1295 or S_PID = 1296 Or Subject = 1005 or Subject = 1458 or Subject = 1031 or Subject = 1038 or Subject = 1045 or Subject = 1051 or
Subject = 1068 or Subject = 1077 or Subject = 1471 or Subject = 1077 or Subject = 1466 or Subject = 1467 or Subject = 1327 or Subject = 1332
or Subject = 1328 or Subject = 1001 or Subject = 1002 or Subject = 1003 or Subject = 1295 or Subject = 1296, "Business Applications",
S_PID = 1057 or Subject = 1478 or Subject = 1057,"Instructional Applications")

I assume you will rewrite it as Dataset.Fieldname.Value for S_PID and Subject


View Siva Gurusamy's profile on LinkedIn

"Software changes. This is a rather obvious statement, but it is a fact that must be ever present in the minds of developers and architects. Although we tend to think of software development as chiefly an engineering exercise, the analogy breaks down very quickly. When was the last time someone asked the designers of the Empire State building to add ten new floors at the bottom, put a pool on the top, and have all of this done before Monday morning? " : Doug Purdy, Microsoft Corporation
Post #664306
Posted Monday, March 21, 2011 9:09 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Wednesday, January 25, 2012 9:40 AM
Points: 3, Visits: 9
Would anybody be able to help me with changing this expression to SSRS? The prompts are PERIOD and YEAR for the user.
Here is the Crystal:

If {Command.Period} = 1 Then
(MonthName(10)) & ' ' & cStr(ToNumber({Command.Year})-1, "####") ELSE
if {Command.Period} = 2 Then
(MonthName(11)) & ' ' & cStr(ToNumber({Command.Year})-1, "####") ELSE
If {Command.Period} = 3 Then
(MonthName(12)) & ' ' & cStr(ToNumber({Command.Year})-1, "####") ELSE
if {Command.Period} = 4 Then
(MonthName(1)) & ' ' & {Command.Year} ELSE
if {Command.Period} = 5 Then
(MonthName(2)) & ' ' & {Command.Year} ELSE
if {Command.Period} = 6 Then
(MonthName(3)) & ' ' & {Command.Year} ELSE
if {Command.Period} = 7 Then
(MonthName(4)) & ' ' & {Command.Year} ELSE
if {Command.Period} = 8 Then
(MonthName(5)) & ' ' & {Command.Year} ELSE
if {Command.Period} = 9 Then
(MonthName(6)) & ' ' & {Command.Year} ELSE
if {Command.Period} = 10 Then
(MonthName(7)) & ' ' & {Command.Year} ELSE
if {Command.Period} = 11 Then
(MonthName(8)) & ' ' & {Command.Year} ELSE
if {Command.Period} = 12 Then
(MonthName(9)) & ' ' & {Command.Year}
Post #1081353
Posted Tuesday, March 22, 2011 1:15 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Tuesday, February 12, 2013 9:35 PM
Points: 226, Visits: 156
hi.. dhans.

this one is general Question..
why do u want to migrate from crystal report to SSRS report..
leaving cost is less.. is there any reason for migrating..

please let me know..
Post #1081767
Posted Tuesday, March 22, 2011 9:26 AM


Right there with Babe

Right there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with Babe

Group: General Forum Members
Last Login: Today @ 4:44 PM
Points: 727, Visits: 1,383
kathleen.zak (3/21/2011)
Would anybody be able to help me with changing this expression to SSRS? The prompts are PERIOD and YEAR for the user.
Here is the Crystal:

If {Command.Period} = 1 Then
(MonthName(10)) & ' ' & cStr(ToNumber({Command.Year})-1, "####") ELSE
if {Command.Period} = 2 Then
(MonthName(11)) & ' ' & cStr(ToNumber({Command.Year})-1, "####") ELSE
If {Command.Period} = 3 Then
(MonthName(12)) & ' ' & cStr(ToNumber({Command.Year})-1, "####") ELSE
if {Command.Period} = 4 Then
(MonthName(1)) & ' ' & {Command.Year} ELSE
if {Command.Period} = 5 Then
(MonthName(2)) & ' ' & {Command.Year} ELSE
if {Command.Period} = 6 Then
(MonthName(3)) & ' ' & {Command.Year} ELSE
if {Command.Period} = 7 Then
(MonthName(4)) & ' ' & {Command.Year} ELSE
if {Command.Period} = 8 Then
(MonthName(5)) & ' ' & {Command.Year} ELSE
if {Command.Period} = 9 Then
(MonthName(6)) & ' ' & {Command.Year} ELSE
if {Command.Period} = 10 Then
(MonthName(7)) & ' ' & {Command.Year} ELSE
if {Command.Period} = 11 Then
(MonthName(8)) & ' ' & {Command.Year} ELSE
if {Command.Period} = 12 Then
(MonthName(9)) & ' ' & {Command.Year}


Hi kathleen.zak,

It's usually better to post a new question as a new thread rather than a reply to an old thread, but here's some help.

The SWITCH function in SSRS will reproduce the if-then logic in your Crystal Reports expression. This function accepts a set of expression/value pairs, evaluates the expressions, and returns the value associated to the first expression that evaluates to TRUE. It looks like this:

=Switch([expression1], [value1], [expression2], [value2], . . . [expressionN], [valueN])

So, with this code:

=Switch(1=0, "NO", 1=1, "YES", 2=2, "WHAT???")

the function will return the string 'YES' because 1=1 is the first expression that evaluates to TRUE.

Use the CStr and CInt functions to convert your input parameters to the appropriate data types to perform the comparisons and concatenations. Also, string literals in SSRS expressions must be enclosed in double quotation marks.

SSRS uses this format to refer to report parameters in expressions: Parameters!YEAR.value

Here's a short version of what your expression would look like rewritten for SSRS (assuming that the Period parameter is integer data type and the Year parameter is a String data type):

=Switch(Parameters!Period.value = 1, MonthName(10) & " " & CStr(CInt(Parameters!Year.value)-1), Parameters!Period.value = 2, (MonthName(11)) & " " & CStr(CInt(Parameters!Year)-1), Parameters!Period.value = 3, (MonthName(12)) & " " & CStr(CInt(Parameters!Year.value)-1))

So, if the user selects Period = 2 and Year = 2010, the function will return the string 'November 2009'.

Hope that helps!
Post #1082058
Posted Tuesday, March 29, 2011 12:10 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Tuesday, April 09, 2013 11:20 AM
Points: 135, Visits: 247
@vinayak.v
I was thinking the same when I migrate to SSRS, but there are lot of advantages in SSRS 2008/R2 than Crystal..
Expression is far better than crystal
SSRS report engine is much faster that Crystalengine for data process... I compared the same report in both platforms.
Using the code behind you can use Vb or C# .net short functions/subs for expressions (the one Kathleen trying to do)..
Embedding to platforms is easy and Report security.
Reporting webservice enables applications to show the report in their pages by report viewer/pdf/etc...
There may be lot.. simply google to get the answer..
Post #1085769
Posted Tuesday, March 29, 2011 12:30 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Tuesday, April 09, 2013 11:20 AM
Points: 135, Visits: 247
@ Kathleen
You can do like wolfkillj said,
Or try this..
Since the period is starts from October
Write expression like below,
= iif(Parameters!Period.value <= 3, MonthName(Parameters!Period.value + 9) + " " + Parameters!Year.Value-1.ToString,
MonthName(Parameters!Period.value -3) + " " + Parameters!Years.value.ToString)

Replace Parameters!Period.Value with Fields!Period.value if you are using Dataset Fields, same for Parameters!Year.Value
Hope this one solves the problem..
Post #1085783
« Prev Topic | Next Topic »

Add to briefcase 12»»

Permissions Expand / Collapse