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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
GreenP
Regular Visitor

Countdistinct with filter on aggregated measure

Hi Experts,

 

We have a table "SALES" like below:

MonthZoneProductCustomerSales TargetAmount Billed
2022-01EASTPR01CUST0112 
2022-02EASTPR01CUST021511
2022-03EASTPR01CUST03 16
2022-01WESTPR01CUST041015
2022-02WESTPR01CUST0517 
2022-03WESTPR01CUST061019
2022-01EASTPR02CUST01 17
2022-02EASTPR02CUST021413
2022-03EASTPR02CUST03 17
2022-01WESTPR02CUST041111
2022-02WESTPR02CUST0514 
2022-03WESTPR02CUST06 20

 

 

We need to show the following calculated measures by Zone and Product in a matrix table:

Count of Customers Targeted = distinct count of CUSTOMER where Sum(Sales Target) is >0

Count of Customers Billed = distinct count of CUSTOMER where Sum(Amount Billed) is >0

Count of Customers Targeted but Not Billed = distinct count of CUSTOMER where Sum(Sales Target) is >0 and Sum(Amount Billed) is <=0

 

Month to be used as slicer (multiple selection).

 

If anyone can help with the DAX for the three calculated measures stated above, it would be of great help.

 

Thanks

1 ACCEPTED SOLUTION
wdx223_Daniel
Super User
Super User

Count of Customers Targeted = COUNTROWS(FILTER(VALUES(Table[Customer]),CALCULATE(Sum(Table[Sales Target]))>0))

Count of Customers Billed = COUNTROWS(FILTER(VALUES(Table[Customer]),CALCULATE(Sum(Table[Amount Billed]))>0))

Count of Customers Targeted but Not Billed = COUNTROWS(FILTER(VALUES(Table[Customer]),CALCULATE(Sum(Table[Amount Billed])<=0&&Sum(Table[Sales Target])>0)))

View solution in original post

3 REPLIES 3
wdx223_Daniel
Super User
Super User

Count of Customers Targeted = COUNTROWS(FILTER(VALUES(Table[Customer]),CALCULATE(Sum(Table[Sales Target]))>0))

Count of Customers Billed = COUNTROWS(FILTER(VALUES(Table[Customer]),CALCULATE(Sum(Table[Amount Billed]))>0))

Count of Customers Targeted but Not Billed = COUNTROWS(FILTER(VALUES(Table[Customer]),CALCULATE(Sum(Table[Amount Billed])<=0&&Sum(Table[Sales Target])>0)))

It works like a charm !! 

One more request: can we create another measure :

 

Total Sales Target of Customers Targeted but Not Billed = Sum(Sales Target) of the CUSTOMERs where Sum(Sales Target) is >0 and Sum(Amount Billed) is <=0

 

Thanks a lot in advance.

CALCULATE(Sum(Table[Sales Target]),FILTER(VALUES(Table[Customer]),CALCULATE(Sum(Table[Amount Billed])<=0&&Sum(Table[Sales Target])>0)))

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.