Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
uaydogdu
Helper I
Helper I

Count (Customerid) except certain confition

Dear All,

I want to get the number of active (AC) customers which are not discontinue (DC) in the same time period.

Here is an example:

I would like to count of Id's in Year 2010.  While counting, I need to exclude those IDs whose status  'AC' and 'DC' in 2010. 

I would like to report yearly.

2010 ... 3

2011 ... 4

 

Is it possible with DAX?

Thanks in Advance

 

IDStatusDate
26854AC05/01/2010
26854DC05/02/2010
26855AC06/02/2010
26856AC07/02/2010
26856AC08/02/2010
26854AC09/02/2011
26855AC11/02/2011
26856AC12/02/2011
26857AC13/02/2011
1 ACCEPTED SOLUTION
OwenAuger
Super User
Super User

Hi @uaydogdu 

 

I would suggest something along these lines:

Customer Count AC but not DC =
VAR AC_Customers =
    CALCULATETABLE ( DISTINCT ( YourTable[ID] ), YourTable[Status] = "AC" )
VAR DC_Customers =
    CALCULATETABLE ( DISTINCT ( YourTable[ID] ), YourTable[Status] = "DC" )
RETURN
    COUNTROWS ( EXCEPT ( AC_Customers, DC_Customers ) )

This measure just takes the set difference between Customers with Status AC and Customers with Status DC, and counts the resulting Customers.

 

This should give the result you expect when filtered by Year (or any other time period).

 

Does this work for you?

 

Regards,

Owen


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn

View solution in original post

2 REPLIES 2
OwenAuger
Super User
Super User

Hi @uaydogdu 

 

I would suggest something along these lines:

Customer Count AC but not DC =
VAR AC_Customers =
    CALCULATETABLE ( DISTINCT ( YourTable[ID] ), YourTable[Status] = "AC" )
VAR DC_Customers =
    CALCULATETABLE ( DISTINCT ( YourTable[ID] ), YourTable[Status] = "DC" )
RETURN
    COUNTROWS ( EXCEPT ( AC_Customers, DC_Customers ) )

This measure just takes the set difference between Customers with Status AC and Customers with Status DC, and counts the resulting Customers.

 

This should give the result you expect when filtered by Year (or any other time period).

 

Does this work for you?

 

Regards,

Owen


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn

Dear Owen ,

I appreciate your answer. I got the way your appraoch, very good. I'll try to implement. 

Regards

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.