Visibility Expression Based On Other Fields Value
Hi All, I’m getting weird results when I make a visible expression based on a value in another field. On some results it does what it should but then others in does the calculation even though the ScheduledCategory = 0?? My production data has no NULL values. In a nutshell I want to average the two datetimes only when the ScheduledCategory = 1. declare @t table ( ScheduledCategory int , ScheduleDate datetime , CompleteDateCancelled datetime ) insert into @t select 1, '1/1/2011 11:00:00 AM' , '1/1/2011 1:00:00 PM' union all select 0, '1/1/2011 9:00 AM' , '1/1/2011 10:00 AM' union all select 0, '1/1/2011 5:00 PM' , '1/1/2011 6:00 PM' select * from @t In my field called Scheduled Dispatch I have following Expression = Avg(Fields!Schedule_Dispatch.Value) Visibility Expression =IIF(Fields!Scheduled.Value = 1, TRUE , FALSE ) I should mention that the above data will work fine. it's when I work with large data sets that I run into trouble. Nothing like working with reports you can't trust! :) Flexpadawan
January 24th, 2011 12:41am

In a nutshell I want to average the two datetimes only when the ScheduledCategory = 1. Hi, Based on your description, you want to get the average of two datetimes (ScheduleDate and CompleteDateCancelled) when ScheduledCategory is 1. However, the field Schedule_Dispatch in the expression = Avg(Fields!Schedule_Dispatch.Value) is included in the table example, is it another field need to be aggregated? Generally, in order to achieve a conditional aggregation, we can nest the IIf function in the aggregate function. For example, we can type in the following expression to a textbox in the group header/footer =Avg(IIf(Fields!ScheduledCategory=1, Fields!Schedule_Dispatch.Value,Nothing)) However, if this cannot meet the needs, please post my details about the table structure and your expectation. Then, I will try to assist you to achieve it. Thanks, Tony ChainTony Chain [MSFT] MSDN Community Support | Feedback to us Get or Request Code Sample from Microsoft Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Free Windows Admin Tool Kit Click here and download it now
January 26th, 2011 1:53am

Worked Perfect!Flexpadawan
February 1st, 2011 10:04am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics