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
Hello,
i have a table with customer data like this:
UserID, OrderID, Date, OrderValue - primary sorted by UserID, secondary by Date
I would like to know these metrics for each customer (all time):
And these for the whole business based on date range (month, quarter, year - for example see these metrics for each month of the last year or last 12 months):
Could someone help please me build these metrics?
Adam
Let's call the table you have "Orders" - it's going to be a lot easier if you also create a table called "Customers" that has a one unqiue row per customer (per unique UserID). Create the Customers table and join it to the Orders table. You should also always have a Calendar table that has one row per day, contiguous meaning don't skip any days.
On the Customer Table as Calculated Columns
First Order Date = CALCULATE( MIN( Orders[Date])) Last Order Date = CALCULATE( MAX( Orders[Date]))
On the Orders Table as Measures
Order Count = DISTINCTCOUNT( Orders[OrderID]) Total Revenue = SUM( Orders[OrderValue]) Average Order Value = DIVIDE( [Total Revenue], [Order Count])
On the Customers Table as Measures
Customer Counter = COUNTROWS( Customers) Customer Count - BEGINNING OF PERIOD = CALCULATE([Customer Counter], FILTER( Customers, Customers[First Order Date] < MIN( Calendar[Date]) && Customer[Last Order Date] > MIN (Calendar[Date]))) Customer Count - END OF PERIOD = CALCULATE([Customer Counter], FILTER( Customers, Customers[First Order Date] <= MAX( Calendar[Date]) && Customer[Last Order Date] > MAX(Calendar[Date]))) Customer Count - AVG ACROSS PERIOD = DIVIDE([Customer Count - BEGINNING OF PERIOD] + [Customer Count - END OF PERIOD],2) New Customers = SUMX(Customers, IF([Customer Count - BEGINNING OF PERIOD] = 0 && [Customer Count - END OF PERIOD] = 1, 1, 0)) Returning Customers = SUMX(Customers, IF([Customer Count - BEGINNING OF PERIOD] = 1 && [Customer Count - END OF PERIOD] = 1, 1, 0)) Lost Customers = SUMX(Customers, IF([Customer Count - BEGINNING OF PERIOD] = 1 && [Customer Count - END OF PERIOD] = 0, 1, 0))
A couple of notes here
Active Customers = DISTINCTCOUNT( Orders[UserID])
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 38 | |
| 37 | |
| 33 | |
| 32 | |
| 29 |
| User | Count |
|---|---|
| 129 | |
| 88 | |
| 79 | |
| 68 | |
| 63 |