Visual Studio reporting expression

I have the following expression in a report in Visual Studio Reporting for the Filter expression of a Group:

=Fields!field1.Value < CInt(2007)

The reason for the CInt() is that the field "field1" is of type Int64 and the Expression sees "2007" as a String value.  So I use CInt() to convert the value "2007" into a Integer so the types match.  However, when running the report, I receive the error

"An error occurred during local report processing.

An error has occurred during report processing.

The processing of FilterExpression for the table ‘table1’ cannot be performed. Cannot compare data of types System.Int64 and System.String. Please check the data type returned by the FilterExpression."

I am very frustrated by this error.  I converted the String type "2007" to an Integer value, yet it is still seeing "2007" as a String value
LVL 15
melli111SharePoint Administrator / DeveloperAsked:
Who is Participating?
gamarrojgqConnect With a Mentor Commented:
ok try this in the EXPRESSION column put this


And in the VALUE column put this


Try using Int64.Parse Method

=Fields!field1.Value < Int64.Parse(2007)

But are you sure that Field1 data type is Int64?
melli111SharePoint Administrator / DeveloperAuthor Commented:
Same exact error when I do that.  I do not see how the expression on the right side, 2007, is still a string type.  Very frustrating.  CInt() is teh conversion method I saw when using the Expression Builder.
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

melli111SharePoint Administrator / DeveloperAuthor Commented:
Okay I figured out part of it.  The error stems from the fact that the Expression sees anything just as is as a String.  For example, "Year" and "2007" are both seen as a string.  "=2007" is seen as a NUMBER.  So that solves the conversion error.  However, the expression is still not filtering out to only everything before 2007.  It pulls ALL of the data
ok, so now how your code looks?  something like this?

=Fields!field1.Value <= 2007
melli111SharePoint Administrator / DeveloperAuthor Commented:
I have attached a screenshot of the expression I am using.  It still does not pull the correct values.
melli111SharePoint Administrator / DeveloperAuthor Commented:
My apologies.  The previous screen shot was the old one.  Here is what I am currently using
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.