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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
jmcph
Helper III
Helper III

Calculating total sales with changing sales price

Hi,

 

I am trying to compute for the Sales amount (using Measures) with changing sales prices every 5 to 8 days. 

the relationship of my model looks like this : 

 

jmcph_1-1613357030553.png

 

The value on my SalesBook are only Quantities, how do i multiply that with the respective sales price on the Masterlist_salesprice?

 

To further elaborate, sample of my data below:

 

Masterlist Sales Price

Product Code               Date                   Price

001                               1/1/21                10

001                               1/7/21                12

001                               1/16/21               8

 

 

SalesBook

Product Code               Date                   Qty

001                              1/3/21                10

001                              1/8/21                15

001                              1/15/21              20

 

My desired Sales Amount is 520. 

 

I hope you can help me with this. Thank you! 

2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@jmcph , A new column in sales table

 

new column =
var _max = maxx(filter(masterlist, masterlist[Product Code] = sales[Product Code] && masterlist[Date] <= sales[Date]),masterlist[Date])
return
maxx(filter(masterlist, masterlist[Product Code] = sales[Product Code] && masterlist[Date] =_max),masterlist[Price]) * sales[Qty]

View solution in original post

ryan_mayu
Super User
Super User

@jmcph 

maybe you can try to create a column to get the price

Column = 
VAR _date=maxx(FILTER('Sales Price','Sales Price'[Date]<='SalesBook'[Date]&&SalesBook[Product Code]=SalesBook[Product Code]),'Sales Price'[Date])
RETURN MAXX(FILTER('Sales Price','Sales Price'[Product Code]=SalesBook[Product Code]&&'Sales Price'[Date]=_date),'Sales Price'[Price])

1.PNG





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

2 REPLIES 2
ryan_mayu
Super User
Super User

@jmcph 

maybe you can try to create a column to get the price

Column = 
VAR _date=maxx(FILTER('Sales Price','Sales Price'[Date]<='SalesBook'[Date]&&SalesBook[Product Code]=SalesBook[Product Code]),'Sales Price'[Date])
RETURN MAXX(FILTER('Sales Price','Sales Price'[Product Code]=SalesBook[Product Code]&&'Sales Price'[Date]=_date),'Sales Price'[Price])

1.PNG





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




amitchandak
Super User
Super User

@jmcph , A new column in sales table

 

new column =
var _max = maxx(filter(masterlist, masterlist[Product Code] = sales[Product Code] && masterlist[Date] <= sales[Date]),masterlist[Date])
return
maxx(filter(masterlist, masterlist[Product Code] = sales[Product Code] && masterlist[Date] =_max),masterlist[Price]) * sales[Qty]

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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