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
mahra-in
Helper II
Helper II

Calculate based on Date and value

Hi

 

Item: AAA121

Available Qty: 10

 

CountryPurchasedDateUnit Price
Brazil206-Jan-21102
Austria411-Jan-21121
Chile722-Jan-21100

 

I have the Item "AAA121" available qty of 10 as inventory, but purchased in 3 countries from other source with date sorted.

 

Calculation i need is Brazil purchased first on 06-Jan-21, we miss to use inventory of value 2 * 102 = 204

                               Austria purchased secodnd 11-Jan-21, we miss to use inventory of value 4 * 121 = 484 

                               Chilepurchased third 22-Jan-21, we miss to use inventory of value 4 (not 7 sinec we have total 10) * 100 = 400

 

Total Miss = 1088

Country wise miss

Brazil - 204

Austria - 484

Chile - 400

 

Regads

Mahes r

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@mahra-in , Try a new column like

new column =
var _sum = sumx(filter(Table, [Date] <= earlier([Date])),[Purchased])
return
if(_sum<=10 , [Purchase] *[Unit Price] , (10 -(_sum -[Purchase]))*[Unit Price])

 

 

or

new column =
var _sum = sumx(filter(Table, [Item] = earlier([Item]) && [Date] <= earlier([Date])),[Purchased])
return
if(_sum<=10 , [Purchase] *[Unit Price] , (10 -(_sum -[Purchase]))*[Unit Price])

View solution in original post

2 REPLIES 2
mahra-in
Helper II
Helper II

I go the result as I expected...Working further on it...If there are any issues, will post it here. Thank you very much for your support

amitchandak
Super User
Super User

@mahra-in , Try a new column like

new column =
var _sum = sumx(filter(Table, [Date] <= earlier([Date])),[Purchased])
return
if(_sum<=10 , [Purchase] *[Unit Price] , (10 -(_sum -[Purchase]))*[Unit Price])

 

 

or

new column =
var _sum = sumx(filter(Table, [Item] = earlier([Item]) && [Date] <= earlier([Date])),[Purchased])
return
if(_sum<=10 , [Purchase] *[Unit Price] , (10 -(_sum -[Purchase]))*[Unit Price])

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.