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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Oomsen
Helper III
Helper III

Forcast costs based on last 6 months

I would like to forecast my costs, based on the average cost in de last 6 months. The outcome of the measure should be presented for al future weeks/months, starting 30 days after today. This is to predict future payables. I will use this forecast in my cashflow prediction, which is a running total of payables, receivables and opportunities. 

 

I created: 

payables average weekly =
VAR week = WEEKNUM(TODAY())
VAR maand = MONTH(TODAY())
VAR jaar = YEAR(TODAY())
VAR datum = DATE(jaar,maand,1)
VAR date2 = EDATE(datum,-6)
VAR date3 = TODAY()
var z = CALCULATE([crediteuren actual],FILTER(ALL(Dimdate),Dimdate[Datum]>=date2&&Dimdate[Datum]<=date3))
VAR g = DIVIDE(z,26)
VAR h = IF(MIN(Dimdate[Datum])-30<=TODAY(),BLANK(),g)
RETURN h

This works to calculate the average costs, but when i add this measure to my running total, the value is dismissed. 

 

 

4 REPLIES 4
Oomsen
Helper III
Helper III

Something is going wrong in de running total of my cashflow. I think the date filtering in my expected costs is the reason, but i'm not sure.
The measure Cashflow is calculating the correct amounts in my opinion.

 

measure expected costs = 
VAR a = DIVIDE(-CALCULATE(SUM(Transacties[amountdc]),Transacties[type]IN{30,31},Grootboekrekeningen[glaccountcode]="1600",DATESBETWEEN(Dimdate[Datum],EDATE(TODAY(),-6),TODAY())),26)
VAR b = IF(MIN(Dimdate[Datum])>=TODAY(),a,BLANK())
RETURN b

measure 
Cashflow = Debiteuren[debiteuren totaal]+[to be invoiced]+Opportunity[opportunity totaal]-Crediteuren[crediteuren totaal]-[expected costs]

measure 
Cashflow RT = CALCULATE(
    [Cashflow],
    FILTER(
        ALLSELECTED('Dimdate'[Datum]),
        ISONORAFTER('Dimdate'[Datum], MAX('Dimdate'[Datum]), DESC)))

 

example.PNG

amitchandak
Super User
Super User

@Oomsen , As you already using a time filter, running total might not work well

Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

 

or try like

 

CALCULATE(SUMx(values(Date[Date]),[payables average weekly ] ) ,filter(allselected('Date'),'Date'[date] <=max('Date'[date])))

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@amitchandak below same sample data.
receivables are from my ERP
payables are from my ERP
costs are historical from GL payables (ERP)
expected are average costs last 6 months
cashflow is receivables - payables - expected
running total is sum of cashflow

MonthWeekreceivablesPayablesCostsExpectedCashflowRunning total
jan1  50   
 2  100   
 3  50   
 4  25   
 5  75   
feb6  50   
 7  100   
 8  50   
 9  100   
mrt10  50   
 11  25   
 12  75   
 13  50   
apr14  100   
 15  50   
 16  100   
 17  50   
may18  25   
 19  75   
 20  50   
 21  100   
 22  50   
jun23  100   
 24  50   
 25  25   
 26  75   
jul27  50   
 28  100   
 29  50   
 30  100   
aug31  50   
 32  25   
 33  75   
 34  50   
 35  100   
sep366010  5050
 3710040  60110,00
 384030  10120,00
 392520  5125,00
 405015  35160,00
okt41   63,46-63,4696,54
 42   63,46-63,4633,08
 43   63,46-63,46-30,38
 44   63,46-63,46-93,85
nov45   63,46-63,46-157,31
 46   63,46-63,46-220,77
 47   63,46-63,46-284,23
 48   63,46-63,46-347,69
dec49   63,46-63,46-411,15
 50   63,46-63,46-474,62
 51   63,46-63,46-538,08
 52   63,46-63,46-601,54
        

Any suggestions?

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.