Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 Reporting Services Development
 display a field in a group != to another field

Author  Topic 

gavakie
Posting Yak Master

221 Posts

Posted - 2009-10-14 : 14:43:57
so i have a report im building and if column a = "X" then i dont want to say show its sales in a group. How would i do that?

JCirocco
Constraint Violating Yak Guru

392 Posts

Posted - 2009-10-14 : 21:39:30
in Hide properties of Sales,
=Iif(Fields.ColumnA.value=X, true, false) so when columnA = X the column would hide.

Could also be in the value entry for sales...
=Iif(Fields.ColumnA.value=X, " ", Fields.Sales.Value) that way if ColumnA=X then force to display blanks otherwise show real value. Both have merits. I like choice 2 because sometimes when you hide a cell, you lose the borders and other attributes.

John
Go to Top of Page

gavakie
Posting Yak Master

221 Posts

Posted - 2009-10-15 : 09:44:15
How would i sum the sales of only the columns I have shown then?
Go to Top of Page

JCirocco
Constraint Violating Yak Guru

392 Posts

Posted - 2009-10-15 : 10:05:52
If you used the second option, the fields that meet your omit criterea would be zero (or Null in this case) so a normal

=SUM(Fields!Sales.Value) should work on a Footer or grouping row.

And, sorry, my previous examples are showing "Fields." instead of the syntactically correct "Fields!"


John
Go to Top of Page

gavakie
Posting Yak Master

221 Posts

Posted - 2009-10-15 : 10:18:36
so this is my sum and its giving me an error.

=sum(Iif(Fields!Letter.Value="Service", " ", ((Fields!Mailed.Value / Fields!Distinct_Customers_Contacted.Value) * Fields!Program_Cost.Value)))
Go to Top of Page

JCirocco
Constraint Violating Yak Guru

392 Posts

Posted - 2009-10-15 : 10:38:29
No, I probably was not clear. You do the Iif on the Table Detail row to over-ride the value if you match the column value.

=Iif(Fields!Letter.Value="Service", " ", ((Fields!Mailed.Value / Fields!Distinct_Customers_Contacted.Value) * Fields!Program_Cost.Value))

But I am not sure now what you would have in the Footer/Totals row.

Maybe you are better off calculating the new value for each row in your SQL (using a CASE statement) and referencing the new field in the report. That way you could eliminate the Iif in the report table cell. Just a thought...

John
Go to Top of Page

gavakie
Posting Yak Master

221 Posts

Posted - 2009-10-15 : 10:43:35
Im coming back reporting services and i thought there was to create new fields from your data and thought that may work. thanks for the help.
Go to Top of Page

JCirocco
Constraint Violating Yak Guru

392 Posts

Posted - 2009-10-15 : 10:46:17
Unfortunately I do not know of a way to Alias the field/column name like you can in SQL

John
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-10-15 : 11:07:44
quote:
Originally posted by gavakie

so this is my sum and its giving me an error.

=sum(Iif(Fields!Letter.Value="Service", " ", ((Fields!Mailed.Value / Fields!Distinct_Customers_Contacted.Value) * Fields!Program_Cost.Value)))


how can you apply sum over " "? i think that should be 0
Go to Top of Page

JCirocco
Constraint Violating Yak Guru

392 Posts

Posted - 2009-10-15 : 11:41:25
" " actually works, treats like null or zero but you are correct. For clarities sake should be 0 and use formatting to zero suppress in the column/row.

John
Go to Top of Page

gavakie
Posting Yak Master

221 Posts

Posted - 2009-10-15 : 16:35:55
=sum(Iif(Fields!Letter.Value= "Service", 0, ((Fields!Mailed.Value / Fields!Distinct_Customers_Contacted.Value) * Fields!Program_Cost.Value))) this???
it still gives an error.
Go to Top of Page

gavakie
Posting Yak Master

221 Posts

Posted - 2009-10-16 : 09:44:26
nevermind i read that wrong
Go to Top of Page
   

- Advertisement -