SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Tablix SUM Filter for 1 Column of 3
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

dtoddp
Starting Member

12 Posts

Posted - 10/03/2012 :  10:39:02  Show Profile  Reply with Quote
Using SSRS 2008 R2, I've got a Tablix report that summarizes totals for a given group item. Where I want to change, is the Hours Column (there are 2 cost, columns that are SUM'd, and one Hours column that is SUM'd).

I'd like to only print one specific Hours value (basically where the index = 2) and NOT SUM the HOURS field like the Cost fields are SUM'd. Was trying to put IIF logic in there so the SUM operation only did so if the Index = 2, but it keeps giving me errors.

How do you not group/SUM a field in a Tablix when the other fields are being SUM'd?

Thanks,

DTP

visakh16
Very Important crosS Applying yaK Herder

India
52325 Posts

Posted - 10/03/2012 :  10:46:08  Show Profile  Reply with Quote
how did you try? like this?

SUM(IIF(Fields!Index.value=2,Fields!Hours.value,0))

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

sunitabeck
Flowing Fount of Yak Knowledge

5155 Posts

Posted - 10/03/2012 :  10:46:43  Show Profile  Reply with Quote
What is the expression you are using? I would think something like this:
=SUM(IIF(Fields!Index.Value=2,Fields!Hours.Value,0))
Go to Top of Page

dtoddp
Starting Member

12 Posts

Posted - 10/03/2012 :  10:53:27  Show Profile  Reply with Quote
This is the SUM statement with no modifications :

=SUM(Fields!Est_Task_Hours.Value)

The Index Value is basically "Fields!TaskIndex.Value"

So the new Statement is =SUM(IIF(Fields!TaskIndex.value=2,Fields!Est_Task_Hours.value,0))

But it gives me errors - reading the log below gives the following:
[rsAggregateOfMixedDataTypes] The Value expression for the textrun ‘Est_Task_Hours.Paragraphs[0].TextRuns[0]’ uses an aggregate function on data of varying data types. Aggregate functions other than First, Last, Previous, Count, and CountDistinct can only aggregate data of a single data type.
Preview complete -- 0 errors, 1 warnings

Thoughts?

D
Go to Top of Page

sunitabeck
Flowing Fount of Yak Knowledge

5155 Posts

Posted - 10/03/2012 :  11:20:11  Show Profile  Reply with Quote
Convert both to the same data type - for example:
=SUM(IIF(Fields!TaskIndex.value=2,CDbl(Fields!Est_Task_Hours.value),CDbl(0)))
Go to Top of Page

dtoddp
Starting Member

12 Posts

Posted - 10/03/2012 :  11:25:18  Show Profile  Reply with Quote
Ok - Excellent, it worked! THANK YOU. Only I'm still a bit confused as to why 2 "different fields" had to have the same data type?
Go to Top of Page

sunitabeck
Flowing Fount of Yak Knowledge

5155 Posts

Posted - 10/03/2012 :  11:54:05  Show Profile  Reply with Quote
Glad to help!

SSRS wants both Fields!Est_Task_Hours.value which would be picked up for some rows and the zero that would be picked up for the rest of the rows to have the same data type so it can add all of that up. Hence the need for conversion.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.09 seconds. Powered By: Snitz Forums 2000