Showing posts with label area. Show all posts
Showing posts with label area. Show all posts

Thursday, March 29, 2012

Field Expression Issue

Hello,

I have a field on my SRS report (a picklist) called new_status

How do I place a statement in the expression area of
this field to get a total of all records where new_status.value = 2

I tried entering this expression and received an error.

=SUM(Fields!new_status.Value = 2)

Any help would be appreciated.

Thanks.

I think you want to do something like this:

=SUM(IIF(Fields!new_status.value=2, CInt(Fields!FieldToSum.value), 0))

Assuming there's a field you want to total when the status field equals 2.

|||

Thank you Corwin,

I think I've done something else wrong here because I'm getting a value of 0 for my count.

Here is how I've set things up..

I created a var called TotalCONN
Set it as a calculated field
Set initial value =0

=SUM(IIF(Fields!new_status.value=2, CInt(Fields!TotalCONN.value), 0))

I am getting the value of 0 returned.

Also, I forgot something.. I have to also check to see if new_status value = 1 as well

Any help is appreciated - I am totally stuck on this one.

=SUM(IIF(Fields!new_status.value=2, CInt(Fields!FieldToSum.value), 0))

I want to have a total for my group where new_status.value=1 or new_status=2

|||

You might want to try tackling it one part at a time:

=SUM(Fields!TotalCONN.value) - does this give you a value of all the records? is it correct?

=SUM(CInt(Fields!TotalCONN.value)) - still get the same result? or did the first attempt result in an error because the CInt was missing?

=SUM(IIF(Fields!new_status.value=2, 1, 0) - do you get a value equal to the number of records with that status?

=SUM(IIF(Fields!new_status.value=1, 1, 0) - do you get a value equal to the number of records with that status?

Is TotalCONN a field or a variable? It may be that Fields!TotalCONN.value is the part that is not valid.

Tuesday, March 27, 2012

field definitions for all user tables

Hello.
Thank you in advance for reading this question.
I posted this question in the newbie area, but have not had a response.
Is there a way to get all the fields for all user tables that are returned
when you do sp_help tablename? I think I have found the columns I need in
'syscolumns' but it is not clear to me how to link the table names to that
syscolumns table to get what I need.
My apolgies for the newbie question. Any help is appreciated!
DianeI just replied to the newusers post.
However, to get table names from syscolumns you can simply call the
OBJECT_NAME() function passing in the id column from syscolumns
(although it's more kosher to use the INFORMATION_SCHEMA views). Like this:
select object_name(id) as [TableName], * from dbo.syscolumns
Hope this helps.
*mike hodgson*
blog: http://sqlnerd.blogspot.com
Diane wrote:

>Hello.
>Thank you in advance for reading this question.
>I posted this question in the newbie area, but have not had a response.
>Is there a way to get all the fields for all user tables that are returned
>when you do sp_help tablename? I think I have found the columns I need in
>'syscolumns' but it is not clear to me how to link the table names to that
>syscolumns table to get what I need.
>My apolgies for the newbie question. Any help is appreciated!
>Diane
>
>|||> Is there a way to get all the fields for all user tables that are returned
> when you do sp_help tablename? I think I have found the columns I need in
> 'syscolumns'
I strongly recommend avoiding the sys tables when possible.
How about http://www.aspfaq.com/2177 ?|||my choice is
sp_msforeachtable @.command1 = "sp_help '?' "
--
Regards
R.D
--Knowledge gets doubled when shared
"Aaron Bertrand [SQL Server MVP]" wrote:

> I strongly recommend avoiding the sys tables when possible.
> How about http://www.aspfaq.com/2177 ?
>
>|||> my choice is
> sp_msforeachtable @.command1 = "sp_help '?' "
Well, sp_msforeachtable is convenient, sure. However I have a two issues
with this approach:
(a) it returns a resultset for each table, whereas with
INFORMATION_SCHEMA.COLUMNS you can easily get all the results in a single
set.
(b) it is an undocumented and unsupported feature, so its behavior can
change or it could disappear from the product altogether with a service
pack, security release or new version of SQL Server.