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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
CJensen
Frequent Visitor

Issue with totals in forecast

Hi Everybody

Im dealing like everyone else with why my totals dosnt add up, but I cant for the life of me figure out what is wrong. 

 

Im trying to forecast subscription consumption for X of months based on the sales of the subscription. E.x. the subscription is billed for 12 months, but the purchase invoices comes monthly. I want to find the forecast for purchases for the rest of the year. Right now im trying to get the number right for 2024, before moving forward. 

Any help would be much appreciated

 

Forecast WORKGODDAMNIT =
var InvoicePeriode = CALCULATE(SUMX(VALUES(Invoices[Sub Periode]),Invoices[Sub Periode]), Invoices[DocumentType] = "Sales")
var eoYEAR = CALCULATE(ENDOFYEAR(Invoices[PostingDate]), Invoices[DocumentType] = "Sales")
var PostDate = CALCULATE(MIN(Invoices[PostingDate]), Invoices[DocumentType] = "Sales")
var calcmonths = DATEDIFF(PostDate, eoYEAR, MONTH)
var NoOfPurch = CALCULATE(COUNTX(Invoices,Invoices[Description]), Invoices[DocumentType] = "Purchase")
var sumofpurch = CALCULATE(SUMX(VALUES(Invoices[Amount]),Invoices[Amount]),Invoices[DocumentType] = "Purchase")
var avgcost = sumofpurch / NoOfPurch

RETURN
calcmonths*avgcost

Example dataset looks like this

 

DocumentType JournalID Description Qty Amount Sub ID SerialNo Postingdate Sub Periode
Purchase 125070 Subscription Item 1 1 5.583,00 837 A00004991 10-01-2024 00:00 1
Purchase 125070 Subscription Item 2 1 108,00 837 A00004990 10-01-2024 00:00 1
Purchase 125649 Subscription Item 1 1 5.583,00 837 A00004991 13-02-2024 00:00 1
Purchase 125649 Subscription Item 2 1 108,00 837 A00004990 13-02-2024 00:00 1
Sales 216499 Subscription Item 1 1 128.346,00 837 A00004991 03-01-2024 00:00 12
Sales 216499 Subscription Item 2 1 2.350,00 837 A00004990 03-01-2024 00:00 12

3 REPLIES 3
bhanu_gautam
Super User
Super User

@CJensen Try using

Forecast_WORKGODDAMNIT =
VAR eoYEAR = CALCULATE(ENDOFYEAR(Invoices[PostingDate]), Invoices[DocumentType] = "Sales")
VAR PostDate = CALCULATE(MIN(Invoices[PostingDate]), Invoices[DocumentType] = "Sales")
VAR calcmonths = DATEDIFF(PostDate, eoYEAR, MONTH)
VAR NoOfPurch = CALCULATE(COUNTX(Invoices, Invoices[Description]), Invoices[DocumentType] = "Purchase")
VAR sumofpurch = CALCULATE(SUMX(VALUES(Invoices[Amount]), Invoices[Amount]), Invoices[DocumentType] = "Purchase")
VAR avgcost = sumofpurch / NoOfPurch

RETURN
calcmonths * avgcost

 




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Hi Bhanu
Thank you so much for your help, it has helped getting me on the right way. 

I think the problems is that the calculation acutally does what ive asked it to, but not want I want to. It shows the correct value for each line, but the total is the average and not the total. Im not sure on how to forward from here.

Anonymous
Not applicable

Hi, @CJensen 

 

Based on the example data you provided, what would you expect the output to be? It can be displayed in an excel format.

 

Best Regards,

Community Support Team _Charlotte

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

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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