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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
ashton99
Regular Visitor

Forecasting Dax help

I've been trying to do this for a while and just cant figure it out. Im trying to "forecast" StartingBalance using palletsfromcontainers and palletsshipped. in excel it would be quite simple but i need it to update itself.

In excel it would be Starting balance + Pallets from containers - Pallets Shipped. The next row would then start with the final value from that and be Forecasted balance (from previous row) + Pallets from containers - Pallets Shipped.

 

This is what my dataset table looks like:

ashton99_0-1722252622159.png

 

thanks

1 ACCEPTED SOLUTION
SamWiseOwl
Super User
Super User

Hi @ashton99 
In this specific scenario could you do Starting value + all prior (Received - Dispatched).

SamWiseOwl_0-1722257381591.png

The DAX is:

Forecast stock =
var firstvalue = maxx(TOPN(1,'Test Table','Test Table'[Date],ASC),[Starting Balance])
--Capture the first Starting balance in the data
var currDate = [Date] --Capture the current date
RETURN
firstvalue + --Add the starting value
SUMX( --Calculate the total of all Pallets received less pallets shipped
    FILTER('Test Table', [Date] <= currDate) --Only include rows on or before current row
    ,[Pallets From Containers] - [Pallets Shipped] --subtract shipped from returned
)
There is a function called OFFSET() and another call ONORBEFORE() which might do what you are thinking.
There is also the possible answer using EARLIER, I wrote a blog about forecast calcuations here.
Let me know if the above isn't doing what you would like.

If it is please mark this as a solution for others to find 🙂

If you are happy with this answer please mark as a solution for others to find !

Kudos are always appreciated! Check out our free Power BI video courses.

View solution in original post

1 REPLY 1
SamWiseOwl
Super User
Super User

Hi @ashton99 
In this specific scenario could you do Starting value + all prior (Received - Dispatched).

SamWiseOwl_0-1722257381591.png

The DAX is:

Forecast stock =
var firstvalue = maxx(TOPN(1,'Test Table','Test Table'[Date],ASC),[Starting Balance])
--Capture the first Starting balance in the data
var currDate = [Date] --Capture the current date
RETURN
firstvalue + --Add the starting value
SUMX( --Calculate the total of all Pallets received less pallets shipped
    FILTER('Test Table', [Date] <= currDate) --Only include rows on or before current row
    ,[Pallets From Containers] - [Pallets Shipped] --subtract shipped from returned
)
There is a function called OFFSET() and another call ONORBEFORE() which might do what you are thinking.
There is also the possible answer using EARLIER, I wrote a blog about forecast calcuations here.
Let me know if the above isn't doing what you would like.

If it is please mark this as a solution for others to find 🙂

If you are happy with this answer please mark as a solution for others to find !

Kudos are always appreciated! Check out our free Power BI video courses.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors