Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredJoin 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.
Hello!
I have a table of orders with a timestamp in datetime format as follows:
Order Id Time of the order customer
1 2020-1-1 00:12:12 1
2 2020-2-3 04:55:05 1
3 2020-3-4 12:30:20 2
4 2020-4-5 00:15:30 3
I need to calculate the average time between orders by customers in minutes (or days). How can this be accomplished using dax?
Imagine I have more customers and more orders. So for instance customer 1 has an average of 2 orders/time difference between their first order and the second one.
@UlisesCiccola , as a new column
[Time of the order] - maxx(filter(Table, [Order Id] =earlier([Order Id]) && [Time of the order] <earlier([Time of the order])) ,[Time of the order])
as a new measure
[Time of the order] - maxx(filter(allselected(Table), [Order Id] =max([Order Id]) && [Time of the order] <max([Time of the order])) ,[Time of the order])
@UlisesCiccola Well, you could create a new column and use EARLIER to calculate time between orders. See my article on Mean Time Between Failure (MTBF) which uses EARLIER: http://community.powerbi.com/t5/Community-Blog/Mean-Time-Between-Failure-MTBF-and-Power-BI/ba-p/3395....
The basic pattern is:
Column =
VAR __Current = [Value]
VAR __PreviousDate = MAXX(FILTER('Table','Table'[Date] < EARLIER('Table'[Date])),[Date])
VAR __Previous = MAXX(FILTER('Table',[Date]=__PreviousDate),[Value])
RETURN
__Current - __Previous
Then you could put the average of this column in a visual along with the customer ID.
@Greg_Deckler what would go in the variable current on this example? The column time of the order?
Thanks in advance!
Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!
Check out the October 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 8 | |
| 6 | |
| 3 | |
| 3 | |
| 3 |
| User | Count |
|---|---|
| 11 | |
| 9 | |
| 8 | |
| 7 | |
| 6 |