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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

To find previous sales

Hi All,

Below is my sample data,

RohiniP-26_0-1611162889727.png

I need to find the immediate previous sales of each product using sales date. The last 'Previous Sales Amount' column is all i need to calculate as a calculated column. For ex: For Product 'A' and sales date '10-01-2020', Sales Amount 1000 is the immediate previous sales this Product.

 

Thanks in Advance....

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous ,

As a new column

New column =
var _max = maxx(filter(Table, [product] =earlier([product]) && [Sales date] < earlier([Sales date])),[Sales date])
return
maxx(filter(Table, [product] =earlier([product]) && [Sales date] =_max ),[Sales Amount])

 

 

As new measure with help from date table

 

Last Day Non Continuous = CALCULATE([sales],filter(ALLSELECTED('Date'),'Date'[Date] =MAXX(FILTER(ALLSELECTED('Date'),'Date'[Date]<max('Date'[Date])),'Date'[Date])))

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.

 

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

View solution in original post

1 REPLY 1
amitchandak
Super User
Super User

@Anonymous ,

As a new column

New column =
var _max = maxx(filter(Table, [product] =earlier([product]) && [Sales date] < earlier([Sales date])),[Sales date])
return
maxx(filter(Table, [product] =earlier([product]) && [Sales date] =_max ),[Sales Amount])

 

 

As new measure with help from date table

 

Last Day Non Continuous = CALCULATE([sales],filter(ALLSELECTED('Date'),'Date'[Date] =MAXX(FILTER(ALLSELECTED('Date'),'Date'[Date]<max('Date'[Date])),'Date'[Date])))

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.

 

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
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.