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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
brunofds
Helper I
Helper I

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
Super User

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.

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

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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