Forum Discussion
Mubar22
2 years agoFrequent Visitor
Customer with only One Purchase Across a Period
Hello Power BI Dev,, I have sales table and I want to count the unique customers that only purchase once across a period. i.e let's say the period is between 2023-2024 so the customer only purchas...
MFelix
Super User
2 years agoHi Mubar22 ,
You are not removing the filter context of the dates to get the full time period so when you get the max and minimum date you get for that specific month and not for the full period of sales try the following code:
OneTimeCustomers =
VAR MaxDate = MAX('Date Table'[Date])
RETURN
COUNTROWS(
FILTER(
CALCULATETABLE( ADDCOLUMNS(
SUMMARIZE('Sales', 'Sales'[companyID]),
"Total Orders", DISTINCTCOUNT('Sales'[invoiceID])
), ALLSELECTED(Date Table)),
[Total Orders] = 1 && MIN('Sales'[OrderDate]) < MaxDate
))