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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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