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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
jaggy123
New Member

How to use regression to estimate trending data until end of month based on current data?

Hi,

 

I have a usecase that I'm trying to build out that I could use help with. Let's say that I have a sales table which is very simple, like:

 

Sale DateSale Amount
2023-01-01$50
2023-01-02$65
2023-01-03$85
2023-01-04

$20

 

I want to be able to use regression or some other way to estimate the total sales amount we could expect to see by the end of the month. The idea is that this calculation should take the real sales amount prior to the maximum date that we have data up to (Jan 4th in this case), and then add that real value to an estimated value for the rest of the month - resulting in a predicted total sales amount per month based on the data we currently have so far.

 

I've got the regression part working, but it's just the combining of the two in a single calculated measure that is not working. Anyone have any idea how this could work?

1 ACCEPTED SOLUTION
Sahir_Maharaj
Super User
Super User

Hello @jaggy123,

 

1. Determine the real sales amount prior to the maximum date available in your data:

RealSalesAmount = 
CALCULATE(
    SUM('Sales'[Sale Amount]),
    'Sales'[Sale Date] <= MAX('Sales'[Sale Date])
)

2. Estimate the sales amount for the remaining days of the month:

EstimatedSalesAmount = 
SUMX(
    CALENDAR(
        MAX('Sales'[Sale Date]) + 1,
        EOMONTH(MAX('Sales'[Sale Date]), 0)
    ),
    [RegressionFormula]  // Replace [RegressionFormula] with your regression formula
)

3. Combine the real sales amount and the estimated sales amount in a single calculated measure:

PredictedTotalSalesAmount = 
[RealSalesAmount] + [EstimatedSalesAmount]

 Let me know if you might require any further assistance.


Did I answer your question? Mark my post as a solution, this will help others!

If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Sahir Maharaj
Data Scientist | Data Engineer | Data Analyst | AI Engineer
P.S. Want me to build your Power BI solution? (Yes, its FREE!)
➤ Lets connect on LinkedIn: Join my network of 15K+ professionals
➤ Join my free newsletter: Data Driven: From 0 to 100
➤ Website: https://sahirmaharaj.com
➤ Email: sahir@sahirmaharaj.com
➤ Want me to build your Power BI solution? Lets chat about how I can assist!
➤ Join my Medium community of 30K readers! Sharing my knowledge about data science and artificial intelligence
➤ Explore my latest project (350K+ views): Wordlit.net
➤ 100+ FREE Power BI Themes: Download Now
LinkedIn Top Voice in Artificial Intelligence, Data Science and Machine Learning

View solution in original post

1 REPLY 1
Sahir_Maharaj
Super User
Super User

Hello @jaggy123,

 

1. Determine the real sales amount prior to the maximum date available in your data:

RealSalesAmount = 
CALCULATE(
    SUM('Sales'[Sale Amount]),
    'Sales'[Sale Date] <= MAX('Sales'[Sale Date])
)

2. Estimate the sales amount for the remaining days of the month:

EstimatedSalesAmount = 
SUMX(
    CALENDAR(
        MAX('Sales'[Sale Date]) + 1,
        EOMONTH(MAX('Sales'[Sale Date]), 0)
    ),
    [RegressionFormula]  // Replace [RegressionFormula] with your regression formula
)

3. Combine the real sales amount and the estimated sales amount in a single calculated measure:

PredictedTotalSalesAmount = 
[RealSalesAmount] + [EstimatedSalesAmount]

 Let me know if you might require any further assistance.


Did I answer your question? Mark my post as a solution, this will help others!

If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Sahir Maharaj
Data Scientist | Data Engineer | Data Analyst | AI Engineer
P.S. Want me to build your Power BI solution? (Yes, its FREE!)
➤ Lets connect on LinkedIn: Join my network of 15K+ professionals
➤ Join my free newsletter: Data Driven: From 0 to 100
➤ Website: https://sahirmaharaj.com
➤ Email: sahir@sahirmaharaj.com
➤ Want me to build your Power BI solution? Lets chat about how I can assist!
➤ Join my Medium community of 30K readers! Sharing my knowledge about data science and artificial intelligence
➤ Explore my latest project (350K+ views): Wordlit.net
➤ 100+ FREE Power BI Themes: Download Now
LinkedIn Top Voice in Artificial Intelligence, Data Science and Machine Learning

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.