This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. We're covering it all. You won't want to miss it.
Learn moreLevel up your Power BI skills this month - build one visual each week and tell better stories with data! Get started
Hi,
I'm trying to find the best way of meassuring new, lost and returning customers from a dataset.
The data is in this format:
So basically I want to be able to see:
who was in the 2017 Edition but not in the 2018 Edition (lost)
who is in both Editions (returning)
who is in the 2018 Edition but not in the 2017 Edition (new)
What is the best way of doing this?
Solved! Go to Solution.
In this scenario, you should use a Year column. Then you need to summarize the previous year amount and current year amount to count each kind of customers.
[New Customers] :=
COUNTROWS (
FILTER (
ADDCOLUMNS (
VALUES ( Table[Customer] ),
"PreviousPurchase", CALCULATE (
COUNTROWS ( Table ),
FILTER ( ALL ( 'Table' ), Table[Year] = MIN ( Table[Year] ) - 1 )
),
"CurrentPurchase", CALCULATE (
COUNTROWS ( Table ),
FILTER ( ALL ( 'Table' ), Table[Year] = MIN ( Table[Year] ) )
)
),
[PreviousPurchase] = 0
&& [CurrentPurchase] <> 0
)
)
[Lost Customers] :=
COUNTROWS (
FILTER (
ADDCOLUMNS (
VALUES ( Table[Customer] ),
"PreviousPurchase", CALCULATE (
COUNTROWS ( Table ),
FILTER ( ALL ( 'Table' ), Table[Year] = MIN ( Table[Year] ) - 1 )
),
"CurrentPurchase", CALCULATE (
COUNTROWS ( Table ),
FILTER ( ALL ( 'Table' ), Table[Year] = MIN ( Table[Year] ) )
)
),
[PreviousPurchase] <> 0
&& [CurrentPurchase] = 0
)
)
[Returning Customers] :=
COUNTROWS (
FILTER (
ADDCOLUMNS (
VALUES ( Table[Customer] ),
"PreviousPurchase", CALCULATE (
COUNTROWS ( Table ),
FILTER ( ALL ( 'Table' ), Table[Year] = MIN ( Table[Year] ) - 1 )
),
"CurrentPurchase", CALCULATE (
COUNTROWS ( Table ),
FILTER ( ALL ( 'Table' ), Table[Year] = MIN ( Table[Year] ) )
)
),
[PreviousPurchase] <> 0
&& [CurrentPurchase] <> 0
)
)
For more details, please refer to a good article below:
http://www.daxpatterns.com/new-and-returning-customers/
Regards,
In this scenario, you should use a Year column. Then you need to summarize the previous year amount and current year amount to count each kind of customers.
[New Customers] :=
COUNTROWS (
FILTER (
ADDCOLUMNS (
VALUES ( Table[Customer] ),
"PreviousPurchase", CALCULATE (
COUNTROWS ( Table ),
FILTER ( ALL ( 'Table' ), Table[Year] = MIN ( Table[Year] ) - 1 )
),
"CurrentPurchase", CALCULATE (
COUNTROWS ( Table ),
FILTER ( ALL ( 'Table' ), Table[Year] = MIN ( Table[Year] ) )
)
),
[PreviousPurchase] = 0
&& [CurrentPurchase] <> 0
)
)
[Lost Customers] :=
COUNTROWS (
FILTER (
ADDCOLUMNS (
VALUES ( Table[Customer] ),
"PreviousPurchase", CALCULATE (
COUNTROWS ( Table ),
FILTER ( ALL ( 'Table' ), Table[Year] = MIN ( Table[Year] ) - 1 )
),
"CurrentPurchase", CALCULATE (
COUNTROWS ( Table ),
FILTER ( ALL ( 'Table' ), Table[Year] = MIN ( Table[Year] ) )
)
),
[PreviousPurchase] <> 0
&& [CurrentPurchase] = 0
)
)
[Returning Customers] :=
COUNTROWS (
FILTER (
ADDCOLUMNS (
VALUES ( Table[Customer] ),
"PreviousPurchase", CALCULATE (
COUNTROWS ( Table ),
FILTER ( ALL ( 'Table' ), Table[Year] = MIN ( Table[Year] ) - 1 )
),
"CurrentPurchase", CALCULATE (
COUNTROWS ( Table ),
FILTER ( ALL ( 'Table' ), Table[Year] = MIN ( Table[Year] ) )
)
),
[PreviousPurchase] <> 0
&& [CurrentPurchase] <> 0
)
)
For more details, please refer to a good article below:
http://www.daxpatterns.com/new-and-returning-customers/
Regards,
Why don't you just use a filter?
Filter on 2017 edition,
Filter on 2018 edition,
Filter on both editions.
https://appsource.microsoft.com/en-us/product/power-bi-visuals/WA104380820?tab=Overview
Or
https://appsource.microsoft.com/en-us/product/power-bi-visuals/WA104380859
I need to show it as a total figure on a card.
As in: total renewals for 2018 Edition.
Hi All
Apologies for reopening this thread but I'm stuck as how to implement the above solution in my report.
I have a Sales FACT table as below:
The report has a Slicer with the FiscalYear from the Dates table. This field coresponds with AccYear in the FACT table.
Am looking as above to show New Customers and Lost Customers both in number and value.
So far I've only tried to get the number of New Customers to work but am failing.
The measure I've created is:
New Customers 2 =
COUNTROWS (
FILTER (
ADDCOLUMNS (
VALUES ( Sales[CustID] ),
"@PreviousPurchase", CALCULATE (
COUNTROWS ( Sales ),
FILTER ( ALL ( 'Sales' ), Sales[AccYear] = SELECTEDVALUE(Dates[FiscalYear])-1 )
),
"@CurrentPurchase", CALCULATE (
COUNTROWS ( Sales ),
FILTER ( ALL ( 'Sales' ), Sales[AccYear] = SELECTEDVALUE(Dates[FiscalYear]) )
)
),
[@PreviousPurchase] = 0 && [@CurrentPurchase]<>0
)
)
Check out the April 2026 Power BI update to learn about new features.
Sign up to receive a private message when registration opens and key events begin.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
| User | Count |
|---|---|
| 30 | |
| 23 | |
| 23 | |
| 16 | |
| 15 |
| User | Count |
|---|---|
| 61 | |
| 35 | |
| 28 | |
| 22 | |
| 21 |