Sharon S (3/8/2013)
I am trying to create the Expression equivalent of the following query:
where TopLevelProjectName = '40 Project Folder'
and TasksName = 'Project Info'
I basically need a working version of this incorrect syntax:
=CountDistinct(IIF(Fields!TopLevelProjectName.Value = "40 Project Folder" AND Fields!TasksName.Value = "Project Info"))
Thanks in advance,
The expression you've suggested is different to the query. The SQL will count every non-null occurance of the field "TasksName" that has the fields TopLevelProjectName = '40 Project Folder'
and TasksName = 'Project Info' on the same row.
A CountDistinct in an SSRS expression will count distinct instances of a field. Which field are you counting? Counting TasksName distinctly where you've specified it must be equal to "Project Info" is not going to work. For example if you did something like this:
=CountDistinct(IIF(Fields!TopLevelProjectName.Value = "40 Project Folder" AND Fields!TasksName.Value = "Project Info",Fields!FieldToBeCounted.value,Nothing))
You would need to specify a third column that might have different distinct info in it that you want to be counting. If you used the TasksName field, then this expression would always return 1 (or possibly 0 if no rows had both of those criteria). I don't think that's what you want here.
If you use a different FieldToBeCounted, and it has data that repeats then again the CountDistinct might not be what you want. You might just want a Count, and if so you could then use TasksName.
It helps to explain why you want to do this, because just giving you this answer might actually not help you at all and produce a sub-optimal outcome for you.