cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
RohiniP-26
Helper III
Helper III

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 IV
Super User IV

@RohiniP-26 ,

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.

 



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Dashboard of My Blogs !! YouTube Channel !! Connect on Linkedin

Proud to be a Super User!

View solution in original post

1 REPLY 1
amitchandak
Super User IV
Super User IV

@RohiniP-26 ,

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.

 



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Dashboard of My Blogs !! YouTube Channel !! Connect on Linkedin

Proud to be a Super User!

View solution in original post

Helpful resources

Announcements
PBI_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

MBAS on Demand

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Get Ready for Power BI Dev Camp

Microsoft named a Leader in The Forrester Wave

Microsoft received the highest score of any vendor in both the strategy and current offering categories.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.