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!Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
Hi everyone,
I would like to make calculations on order dates based on the previous order dates of specific customers.
So far, I've add a "SalesSequence" column in my "Sales" table using this Dax formula:
SalesSequence =
VAR CurrentOrderDate = Sales[OrderDate]
RETURN
COUNTROWS(
FILTER(
CALCULATETABLE(
Sales;
ALLEXCEPT(Sales;Sales[AccountId])
);
Sales[OrderDate] <= CurrentOrderDate
)
)
This should help me get the previous order date of a specific customer.
Here is an example of the column "PreviousOrderDate" I'd like to add to my "Sales" table:
| AccountId | OrderDate | SalesAmount | SalesSequence | PreviousOrderDate |
| a1 | 01.01.2015 | 100 | 1 | |
| a1 | 12.01.2015 | 200 | 2 | 01.01.2015 |
| b1 | 23.02.2016 | 140 | 1 | |
| b1 | 20.10.2017 | 50 | 2 | 23.02.2016 |
| a1 | 14.10.2016 | 100 | 3 | 12.01.2015 |
| c1 | 20.08.2016 | 200 | 1 | |
| a1 | 12.10.2017 | 300 | 4 | 14.10.2016 |
Your help will be much appreciated !
Thanks in advance !
R.
Solved! Go to Solution.
@Anonymous
Try with this:
Column 2 =
CALCULATE (
VALUES ( Table1[OrderDate] ),
FILTER (
ALL ( Table1 ),
Table1[SalesSequence]
= EARLIER ( Table1[SalesSequence] ) - 1
&& Table1[AccountId] = EARLIER ( Table1[AccountId] )
)
)Regards
Victor
@Anonymous
Hi, try with this calculated column.
PreviousOrderDate =
CALCULATE (
LASTNONBLANK ( Table1[OrderDate]; Table1[OrderDate] ),
FILTER (
Table1,
Table1[OrderDate] < EARLIER ( Table1[OrderDate] )
&& Table1[AccountId] = EARLIER ( Table1[AccountId] )
)
)Regards
Victor
Lima - Peru
Thanks for your answer.
Is there another way to do it? Because I tried yours and it's still calculating 15 minutes later (there is +3.8M rows in my sales table).
@Anonymous
Try with this:
Column 2 =
CALCULATE (
VALUES ( Table1[OrderDate] ),
FILTER (
ALL ( Table1 ),
Table1[SalesSequence]
= EARLIER ( Table1[SalesSequence] ) - 1
&& Table1[AccountId] = EARLIER ( Table1[AccountId] )
)
)Regards
Victor
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
| User | Count |
|---|---|
| 103 | |
| 80 | |
| 62 | |
| 50 | |
| 45 |