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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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