Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
Anonymous
Not applicable

Display previous date per ID in power query

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 IDDate
101-01-2021
101-02-2021
105-02-2021
231-01-2021
205-02-2021
307-02-2021

 

And my desired result:

Customer IDDatePrevious Date
101-01-2021 
101-02-202101-01-2021
105-02-2021 01-02-2021
231-01-2021 
205-02-2021 31-01-2021
307-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!

1 ACCEPTED SOLUTION
poweryogesh
Frequent Visitor

@Anonymous 
This thread might solve your issue
Previous Date using M query  

View solution in original post

6 REPLIES 6
poweryogesh
Frequent Visitor

@Anonymous 
This thread might solve your issue
Previous Date using M query  

Anonymous
Not applicable

Thanks @poweryogesh . The function that @ImkeF wrote did the trick.

@Anonymous 
Glad to see the thread worked for you 

amitchandak
Super User
Super User

@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 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

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.

amitchandak
Super User
Super User

@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 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Kudoed Authors