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
 SQL Server 2008 Forums
 Analysis Server and Reporting Services (2008)
 Count Distinct gives me incorrect result

Author  Topic 

Villanuev
Constraint Violating Yak Guru

478 Posts

Posted - 2013-11-11 : 22:11:28
Hi,

I have an SSSRS report that i need to count a column Location Category. Need to display the result out side the table. see below my statement. The result set display is 1 even i dont have any data on this column except an space or blank.

LOcation category
-------------------
PB-L1-01
PB-L1-01
PB-L1-01
PB-L1-01
Blank space
Blank Space

--This give me 2, remove the PB-L1-01, this give me 1 using below statement.


=CountDistinct(IIF(Fields!LOCATIONCATEGORY.Value <> "",1,0),"DETAIL_DS")

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-11-12 : 01:57:53
it should be
=CountDistinct(IIF(Fields!LOCATIONCATEGORY.Value <> "",Fields!LOCATIONCATEGORY.Value,Nothing),"DETAIL_DS")

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

Villanuev
Constraint Violating Yak Guru

478 Posts

Posted - 2013-11-12 : 20:49:23
Hi Visakh, thanks for the reply.

Under Catetory--Dataaset, Item---DETAIL_DS, then under Values, this is the contents,,First(Fields!LOCATIONCATEGORY.Value, "DETAIL_DS")

Try this based on your suggestion but i got an error.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-11-13 : 07:51:11
Catetory--Dataaset, Item---DETAIL_DS
thats not what code you posted designates
as per that dataset name is DETAIL_DS

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -