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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Alicetemitope
Frequent Visitor

Forecasting using previous day value

Hi Team, I hope you all are doing great. I am a newbie to DAX and PBI annd currenntly working on a task to predict cost. I had to calculate the slope(which I did using the Linest function) and add this slope to the preceeding value(where preceeding value = previous day cost). so,

cost prediction for today= actual value of previous day + slope and if there is no actual value present(in the case of future days), then 

cost prediction for future = last calculated cost prediction + slope 

 

so I wrote a dax formula,

cost prediction =
var _PreviousDayCost = CALCULATE([Amortized Cost(€)], PREVIOUSDAY(DIM_Date[Date]))
var _predictedcost = _PreviousDayCost + [Slope]
return
_predictedconsumption
 
evreything works fine until when I don't have any actual and it just returns the slope. is there a way to reference the previously calculated prediction so the right prediction is populated.like in excel where previous cell is referenced. 
 
Thanks in advance for your help and support
Here is a result of my current formulaHere is a result of my current formulavalue to be addedvalue to be added
1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

@Alicetemitope No, but you could do this potentially:

Measure = 
  VAR __Date = MAX('Table'[Date])
  VAR __Table = 
    ADDCOLUMNS(
      DISTINCT(ALLSELECTED('Table'[Date])),
      "__DailyCost",[Amortized Cost(E)
    )
  VAR __MaxDate = MAXX(FILTER(__Table, [__DailyCost] <> BLANK()), [Date])
  VAR __Value = MAXX(FILTER(__Table, [Date] = __MaxDate), [__DailyCost])
  VAR __Result = __Value * [Slope]
RETURN
  __Result

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

2 REPLIES 2
Greg_Deckler
Community Champion
Community Champion

@Alicetemitope No, but you could do this potentially:

Measure = 
  VAR __Date = MAX('Table'[Date])
  VAR __Table = 
    ADDCOLUMNS(
      DISTINCT(ALLSELECTED('Table'[Date])),
      "__DailyCost",[Amortized Cost(E)
    )
  VAR __MaxDate = MAXX(FILTER(__Table, [__DailyCost] <> BLANK()), [Date])
  VAR __Value = MAXX(FILTER(__Table, [Date] = __MaxDate), [__DailyCost])
  VAR __Result = __Value * [Slope]
RETURN
  __Result

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler thank you so much for your help. Your suggestion helped in fine tuning my calculations. In the end, we stopped this approach and decided to use OLS for the predictions. which was much easier and made more sense. 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.