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

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

Reply
ronaldbalza2023
Continued Contributor
Continued Contributor

Count of Total Customers by Tasks

Hi everyone, I was puzzle how to count the total number of customers by Tasks by the given below scenario. Thanks in advance

Two tables have the inactive relationships: Tasks[Jobs Job Client ID] and Clients[ID]

DAX Measure

Total Customers by Tasks = 
CALCULATE (
    DISTINCTCOUNT ( Clients[ID] ),
    FILTER ( Clients, Clients[Is Prospect] = "No" ),
    USERELATIONSHIP ( Clients[ID], Tasks[Jobs Job Client ID] )
)

ronaldbalza2023_1-1663121545192.png

 

 

1 ACCEPTED SOLUTION
TomMartens
Super User
Super User

Hey @ronaldbalza2023 ,

 

I do not understand your question because I do not see the problem.

 

Nevertheless, I would write the measure like this

 

 

Total Customers by Tasks = 
CALCULATE (
    DISTINCTCOUNT ( Clients[ID] ),
    Clients[Is Prospect] = "No",
    USERELATIONSHIP ( Clients[ID], Tasks[Jobs Job Client ID] ),
    CROSSFILTER( Clients[ID], Tasks[Jobs Job Client ID], BOTH )
)

 

 

Referencing only the column [Is Prospect] as a filter is more efficient than using the function FILTER (reading the complete table, all the columns), as the vertipaq engine does not need to read the whole table.

See CROSSFILTER here: CROSSFILTER – DAX Guide
CROSSFLTER is necessary as you want the column on the many-side of the relationship filtering the table of the one-side (at least this is my understanding of the problem you are trying to solve.

Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

View solution in original post

4 REPLIES 4
TomMartens
Super User
Super User

Hey @ronaldbalza2023 ,

 

I do not understand your question because I do not see the problem.

 

Nevertheless, I would write the measure like this

 

 

Total Customers by Tasks = 
CALCULATE (
    DISTINCTCOUNT ( Clients[ID] ),
    Clients[Is Prospect] = "No",
    USERELATIONSHIP ( Clients[ID], Tasks[Jobs Job Client ID] ),
    CROSSFILTER( Clients[ID], Tasks[Jobs Job Client ID], BOTH )
)

 

 

Referencing only the column [Is Prospect] as a filter is more efficient than using the function FILTER (reading the complete table, all the columns), as the vertipaq engine does not need to read the whole table.

See CROSSFILTER here: CROSSFILTER – DAX Guide
CROSSFLTER is necessary as you want the column on the many-side of the relationship filtering the table of the one-side (at least this is my understanding of the problem you are trying to solve.

Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Hi @TomMartens, thanks for taking the time on this. It is the crossfilter function that I am looking for. As you can see on the snapshot table, it only aggregates the data and is not segregated the total number of customers by tasks. Thanks and appreciated it 🙂

Hey @ronaldbalza2023 ,

 

please let me know if the CROSSFILTER function provides what you are looking for.

 

Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

It is @TomMartens ...I am looking for a ways to optimize the dax 🙂 Thanks again for your help.

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.

Top Solution Authors