cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
brunofds
Frequent Visitor

Average price / INVENTORY / STOCK MARKET - DAX measure

Hello! 

 

I've been dealing with this problem a looong time.

 

A sample of may dataset is available in this link:

 

https://1drv.ms/u/s!ApPuttHgFDRRgYkpdIbe-OSHnLBhuA

 

 

I'm trying to calculate some data from the stock market.The process is similar to inventory valuation and i've used lot's of insights from DAX PATTERNS website, but i'm stuck with this issue.

 

Below is a screenshot of my dataset, which i've put some fictional data  just to make it more clear:

 

screenshot.png

 

 

I want to compute three measures:

  • Profit
  • Gross AVG Price
  • Net AVG Price

 

 

The issue is those measures are based on "previous rows". 

 

The best way to show is demonstrate by this Excel file, in which i was able to compute those "measures" (columns with yellow headers) : 

stocks.xlsx

 

 

 

 

I was told to do this on power query, using a snapshot table, but i couldnt make it. But i will gladly accept this as a solution 🙂

 

Thank you!

 

 

 

1 ACCEPTED SOLUTION

Hi, @brunofds 

 

The recursive calculation mode is really not suitable for use in powerbi. I tried to do it,but it was very complicated, and there were some problems, and I couldn't solve it completely. So it is recommended that you use the calculated results in excel and bring them to powerbi for use.

 

Best Regards

Janey Guo

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
lbendlin
Super User III
Super User III

use either List.Accumulate() in Power Query, or PRODUCTX() in DAX. Whatever your preference is (and of course it depends if the result can be impacted by filter choices)

Could you be a little more specific? I'm aware of PRODUCTX, but not sure how does it solves it, since i'd need previously have the "NET AVG PRICE"  measure as shows on the excel file....

 

Thank you.

Hi, @brunofds 

 

The recursive calculation mode is really not suitable for use in powerbi. I tried to do it,but it was very complicated, and there were some problems, and I couldn't solve it completely. So it is recommended that you use the calculated results in excel and bring them to powerbi for use.

 

Best Regards

Janey Guo

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Thank you for your time and efforts. I really appreciate it.

Helpful resources

Announcements
PBI User Groups

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

April Update

Check it Out!

Click here to read more about the April 2021 Updates!

secondImage

The largest Power BI virtual conference

100+ sessions, 100+ speakers, Product managers, MVPs, and experts. All about Power BI. Attend online or watch the recordings.

secondImage

Experience what’s next for Power BI

See the latest Power BI innovations, updates, and demos from the Microsoft Business Applications Launch Event.