Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
I have a transactional table that records a customer record over time. Customers come in and out over time and I'd like to calculate how many are kept from some starting point.
For example, if you arrive in period 1, did you return in period 2 or subsequent periods.
Table:
| CustomerID | PeriodID |
| 1234 | 1 |
| 1345 | 1 |
| 2567 | 1 |
| 3678 | 1 |
| 4890 | 1 |
| 5789 | 1 |
| 6890 | 1 |
| 5421 | 1 |
| 1234 | 2 |
| 1345 | 2 |
| 2567 | 2 |
| 1111 | 2 |
| 2222 | 2 |
| 6890 | 2 |
| 3678 | 3 |
| 1111 | 3 |
Outcome:
| First Period | Period | Retained Customers | % Retained |
| 1 | 1 | 8 | 100% |
| 1 | 2 | 3 | 38% |
| 1 | 3 | 1 | 13% |
I tried a bi-directional join through a table of all unique customerid's and a copy of the original table but the results were incorrect. Hope this makes sense. Thanks.
Solved! Go to Solution.
Hi @FearDerBeard,
In your sceario, do you only need to count the retained customers start from PeriodId 1?
If so, please refer to below DAX formula to see whether it works for you.
Column1 =
LOOKUPVALUE (
'retained over time'[CustomerID],
'retained over time'[CustomerID], 'retained over time'[CustomerID],
'retained over time'[PeriodID], 'retained over time'[PeriodID] - 1
)
Column2 =
IF (
'retained over time'[PeriodID] = 1,
CALCULATE (
DISTINCTCOUNT ( 'retained over time'[CustomerID] ),
FILTER ( 'retained over time', 'retained over time'[PeriodID] = 1 )
),
CALCULATE (
COUNT ( 'retained over time'[Column1] ),
ALLEXCEPT ( 'retained over time', 'retained over time'[PeriodID] )
)
)
Regards,
Yuliana Gu
Hi @FearDerBeard,
In your sceario, do you only need to count the retained customers start from PeriodId 1?
If so, please refer to below DAX formula to see whether it works for you.
Column1 =
LOOKUPVALUE (
'retained over time'[CustomerID],
'retained over time'[CustomerID], 'retained over time'[CustomerID],
'retained over time'[PeriodID], 'retained over time'[PeriodID] - 1
)
Column2 =
IF (
'retained over time'[PeriodID] = 1,
CALCULATE (
DISTINCTCOUNT ( 'retained over time'[CustomerID] ),
FILTER ( 'retained over time', 'retained over time'[PeriodID] = 1 )
),
CALCULATE (
COUNT ( 'retained over time'[Column1] ),
ALLEXCEPT ( 'retained over time', 'retained over time'[PeriodID] )
)
)
Regards,
Yuliana Gu
Perhaps something along the lines of this:
Customers Retained = IF(SUM(Customers[PeriodID])=1,COUNT([PeriodID]),COUNT([PeriodID]) - CALCULATE(COUNT([PeriodID]),ALL(Customers[CustomerID]),FILTER(Customers,[PeriodID]=[PeriodID]-1)))
That isn't the entire solution because it doesn't match customer id's but may get you close.
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
Check out the November 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 59 | |
| 46 | |
| 42 | |
| 23 | |
| 18 |
| User | Count |
|---|---|
| 193 | |
| 123 | |
| 99 | |
| 67 | |
| 49 |