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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
TE
Frequent Visitor

Calculate the amount of companies without a contract

Hi!

 

I'm trying to calculate a historical count of customers that don't have an ongoing contract. So I want to have a chart diagram showing the amount of former clients at each point in time. Here is what I have at the moment:

 

Former clients = CALCULATE(DISTINCTCOUNT(ParentCompany[id]), FILTER(ALLSELECTED('Contract'), 'Contract'[EndDate] < MAX((DateTabe[Date]))))
 
However, this dax counts all customers that have at least one contract that has ended as a former customer, even if they still have an ongoing contract. Can anyone help me with this one?
 
Thanks!
 
TE
1 ACCEPTED SOLUTION
v-juanli-msft
Community Support
Community Support

Hi @TE 

It seems a customer has many contacts at different dates,

Your measure show the customers including who have contacts before the specific date and after the specific date.

But what you expect is to only count the customers who's contacts are all before the specific date.

Is my understanding correct?

 

If so, 

Create a table which is not connected to other tables

calendar = CALENDARAUTO()

2.png

Create measures in "contacts" table

max_date = MAX('calendar'[Date])

max_end_date = CALCULATE(MAX(contacts[end date]),ALLEXCEPT(contacts,contacts[customer id]))

Former clients = CALCULATE(DISTINCTCOUNT(customer[customer id]),FILTER(ALLSELECTED(contacts),[max_end_date]<[max_date]))

1.png

Best Regards
Maggie

 

Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-juanli-msft
Community Support
Community Support

Hi @TE 

It seems a customer has many contacts at different dates,

Your measure show the customers including who have contacts before the specific date and after the specific date.

But what you expect is to only count the customers who's contacts are all before the specific date.

Is my understanding correct?

 

If so, 

Create a table which is not connected to other tables

calendar = CALENDARAUTO()

2.png

Create measures in "contacts" table

max_date = MAX('calendar'[Date])

max_end_date = CALCULATE(MAX(contacts[end date]),ALLEXCEPT(contacts,contacts[customer id]))

Former clients = CALCULATE(DISTINCTCOUNT(customer[customer id]),FILTER(ALLSELECTED(contacts),[max_end_date]<[max_date]))

1.png

Best Regards
Maggie

 

Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Excellent! Thanks @v-juanli-msft, this worked out just like I wanted to! 

 

Is there any way to calculate the same measure but for the previous month or quarter so I can count the change in former clients?

 

Thanks so much!

 

TE

TE
Frequent Visitor

Hi!

 

The original problem is solved, but I still can't find a solution for quarter over quarter calculation for this. Can anyone help? @v-juanli-msft ??

 

Thanks!

 

TE

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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