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!View all the Fabric Data Days sessions on demand. View schedule
Hi,
Similar to this thread for DAX, I would like to add a column in Power Query that calculates the previous date of a sale per customer ID.
Example data:
| Customer ID | Date |
| 1 | 01-01-2021 |
| 1 | 01-02-2021 |
| 1 | 05-02-2021 |
| 2 | 31-01-2021 |
| 2 | 05-02-2021 |
| 3 | 07-02-2021 |
And my desired result:
| Customer ID | Date | Previous Date |
| 1 | 01-01-2021 | |
| 1 | 01-02-2021 | 01-01-2021 |
| 1 | 05-02-2021 | 01-02-2021 |
| 2 | 31-01-2021 | |
| 2 | 05-02-2021 | 31-01-2021 |
| 3 | 07-02-2021 |
Since I have milions of rows, a calculated column in DAX is not preferred since it slows down the pbix a lot.
Does anyone know how to do this in power query?
Thanks!
Solved! Go to Solution.
@Anonymous
Glad to see the thread worked for you
@Anonymous , both power query and Dax is going to take load time.
Both will be calculated columns
min = Maxx(filter(Table, [Customer ID] = earlier([Customer ID] ) && [Date] < earlier([Date]) ), [Date] )
I think no of steps in power query vs DAX, it should take same load time
Hi @amitchandak ,
Thanks you for your reply. My Power BI file has become very slow due to calculated columns, it takes minutes for a measure to appear when I press on 'new measure'.
In this thread I've read that this is caused by having too many calculated columns. Therefore, I want to push my calculations back to Power Query. Loading time of the queries is not a problem, but having to wait minutes for every filter/measure I simply press in desktop is not workable.
@Anonymous , both power query and Dax is going to take load time.
Both will be calculated columns
min = Maxx(filter(Table, [Customer ID] = earlier([Customer ID] ) && [Date] < earlier([Date]) ), [Date] )
I think no of steps in power query vs DAX, it should take same load time
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!