Wednesday, January 25, 2012

Counting unique values conditionally using SSRS

Sometimes you want to count unique values based on filtered conditions. For example, count the number accounts and contacts in which you have a qualified opportunity.  You would be running the query on the opportunity and the joining back to contact and then account. To do this:

countdistinct(iif(<parameter that makes opportunity qualified>,<field with distinct value you want to count>, nothing))

Hope this helps someone out there.

No comments:

Post a Comment