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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
leniorcortivo
Advocate I
Advocate I

How to Calculate the Average Purchase Price over Multiple Purchases in Time

Hello Dear Coleagues,

 

Need your knwoledge to figure out this calculation. Please see the following transactions.

 

CodeDateOperationQuantityUnit PriceCostCumulative QuantityAverage Unit PriceAverage Unit Price + Cost
ABCD09/16/2019Purchase3U$ 156,10U$ 0,133U$ 156,10U$ 156,14
ABCD10/15/2019Purchase2U$ 164,40U$ 0,105U$ 159,42U$ 159,47
ABCD01/05/2020Purchase1U$ 171,00U$ 0,056U$ 161,35U$ 164,40
ABCD01/08/2020Sell3U$ 187,36U$ 0,113U$ 161,35U$ 161,40
ABCD01/10/2020Sell2U$ 187,50U$ 0,111U$ 161,35U$ 161,40
ABCD01/15/2020Sell1U$ 187,50U$ 0,110U$ 0,00U$ 0,00
ABCD03/09/2020Purchase1U$ 161,50U$ 0,041U$ 161,50U$ 161,54
ABCD06/30/2020Purchase1U$ 169,45U$ 0,042U$ 165,48U$ 165,52
ABCD01/13/2021Purchase3U$ 160,00U$ 0,155U$ 162,19U$ 162,24
ABCD08/09/2021Purchase2U$ 135,49U$ 0,157U$ 154,56U$ 154,62
ABCD09/01/2021Purchase4U$ 141,03U$ 0,1511U$ 149,64U$ 149,69
ABCD09/16/2021Purchase2U$ 141,24U$ 0,1513U$ 148,35U$ 148,40

 

The chalenge is to calculate correctly the last column, where over time when you hit 0 in your cumulative quantity column you must "restart" your average unit price for that point forward. When a selling operation is listed, the average unit price must not change.

 

This is a table with a single code, ABCD, but the same data source could have multiple codes. I just kept simple with one code to be more easier to understand.

 

The desired result would be a table with a single line for the code ABCD and your current (latest) Average Unit Price.

 

Thank you!

5 REPLIES 5
Syndicate_Admin
Administrator
Administrator

Good day, you have a solution for this post?, I have the same doubt.

Hello my friend. Not yet!

v-jingzhang
Community Support
Community Support

Hi @leniorcortivo 

 

Can we think that the first 7 columns (Code, Date, Operation ... Cumulative Quantity) are what you already have and the last two columns (Average Unit Price, Average Unit Price + Cost) are what you want to achieve? It is because if you already have all these 9 columns data, you just need to get data from the last line for each code, right?

 

Best Regards,
Community Support Team _ Jing

vanessafvg
Super User
Super User

so the table you have provided, is that the data that is given to you or are you asking to provide the results in that table.

 

Not sure if you asking for 2 things here?

 

create an average based on unit price cost, averaged between 0 and 0?

 

and then a single line showing the latest?   for a specific code?

 

what is the desired output in an example, can you show or is it just the last line of the table above?





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




The last two columns we want to achive in the calculation. The data is on the example table just to be compared as the correct result that should be achieved in the solution.

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.