cancel
Showing results for
Search instead for
Did you mean:
Regular Visitor

## Cohort Analysis - DAX

Hi Folks

I want to create a Cohort Analysis. This involves calculating the the percentage of a cohort that is left in each of the subsequent months  following an initial signup. The screenshot below demonstrates the basic concept.  I want to avoild hard coding any date filters as a new cohort is added each month.

I am thinking the solution involves a CALCULATE formula, but I am getting tripped up with the DAX to identify the denominator in the % calculation (the starting number of customers in each Cohort (40 in the first cohort, 35 in the second 30  in the 3rd cohort).

Can anyone help me out with the DAX?

Any help is much appreciated.  Excel/ PowerPivot File attached.

Thanks Steve

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super Contributor

## Re: Cohort Analysis - DAX

Hi Steve,

Here are a couple of ideas I can think of depending on the logic you want to apply (they give the same answer using your sample data).

These are additive over signup month (which you may want) and invoice month (which you may not want). You can modify that behaviour if needed.

1. Denominator = For each Signup Month, Number of customers where Invoice Month = Signup Month

```=
DIVIDE (
[Count of Customer ID],
CALCULATE (
[Count of Customer ID],
GENERATE (
VALUES ( Table1[Signup Month] ),
FILTER (
ALL ( Table1[Invoice_Month] ),
Table1[Invoice_Month] = Table1[Signup Month]
)
)
)
)```

2. Denominator = For each Signup Month, Number of customers in first Invoice Month with nonblank customers

```=
DIVIDE (
[Count of Customer ID],
CALCULATE (
[Count of Customer ID],
GENERATE (
VALUES ( Table1[Signup Month] ),
FIRSTNONBLANK ( ALL ( Table1[Invoice_Month] ), [Count of Customer ID] )
)
)
)```

Owen 🙂

Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!

4 REPLIES 4
Highlighted
Super Contributor

## Re: Cohort Analysis - DAX

Hi Steve,

Here are a couple of ideas I can think of depending on the logic you want to apply (they give the same answer using your sample data).

These are additive over signup month (which you may want) and invoice month (which you may not want). You can modify that behaviour if needed.

1. Denominator = For each Signup Month, Number of customers where Invoice Month = Signup Month

```=
DIVIDE (
[Count of Customer ID],
CALCULATE (
[Count of Customer ID],
GENERATE (
VALUES ( Table1[Signup Month] ),
FILTER (
ALL ( Table1[Invoice_Month] ),
Table1[Invoice_Month] = Table1[Signup Month]
)
)
)
)```

2. Denominator = For each Signup Month, Number of customers in first Invoice Month with nonblank customers

```=
DIVIDE (
[Count of Customer ID],
CALCULATE (
[Count of Customer ID],
GENERATE (
VALUES ( Table1[Signup Month] ),
FIRSTNONBLANK ( ALL ( Table1[Invoice_Month] ), [Count of Customer ID] )
)
)
)```

Owen 🙂

Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!

Regular Visitor

## Re: Cohort Analysis - DAX

Excellent! Thanks Owen. Just what I was after.

Member

## Re: Cohort Analysis - DAX

where is the signup month formula?

Frequent Visitor

## Re: Cohort Analysis - DAX

this formula does not work. it says too few arguments are trying to pass the filter function

## Helpful resources

Announcements

#### New Topics Started Badges Coming

We're releasing new versions of the badge that everyone's talking about. ;) Check your inbox for notifications.

#### Save the new date (and location)!

Our business applications community is growing—so we needed a different venue, resulting in a new date and location. See you there!

#### Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

#### Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

Top Solution Authors
Top Kudoed Authors (Last 30 Days)