cancel
Showing results for
Did you mean:
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

Accepted Solutions
Community Support Team

## Re: Calculate the amount of companies without a contract

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()`

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]))```

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.

3 REPLIES 3
Community Support Team

## Re: Calculate the amount of companies without a contract

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()`

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]))```

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.

Frequent Visitor

## Re: Calculate the amount of companies without a contract

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

Frequent Visitor

## Re: Calculate the amount of companies without a contract

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

Announcements

#### Meet the 2020 Season 1 Power BI Super Users!

It’s the start of a new Super User season! Learn all about the new Super Users and brand-new tiered recognition system.

#### Super User Challenge: Can You Solve These?

We're celebrating the start of the New Super User season with our first ever Super User 'Can You Solve These?' challenge.

#### Power BI Desktop Update - February 2020

We are super excited for our update this month, as we are releasing two of our top community requests!