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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
gauravnarchal
Post Prodigy
Post Prodigy

Forecast sales for each (month) and (Year)

Hello, I want to get the forecast for sales for each (month) and (Year).

 

While forecasting, I want to consider only 20% of sales for Saturday and Sunday, and all other days can be 100%.

 

I have the PBI file with the sample data for your reference. Click Here

1 ACCEPTED SOLUTION
v-yangliu-msft
Community Support
Community Support

Hi  @gauravnarchal ,

Shared link time expired, I created some data:

vyangliumsft_0-1649303541029.png

Here are the steps you can follow:

1. Create calculated column.

year = YEAR('Table'[date])
Month = MONTH('Table'[date])
week = WEEKDAY('Table'[date],2)
IF =
IF(
    'Table'[week]>=1&&'Table'[week]<=5,1,0)

2. Create measure.

Month forecastA =
var _avgamount=CALCULATE(AVERAGE('Table'[amount]),FILTER(ALL('Table'),'Table'[year]=MAX('Table'[year])&&'Table'[Month]=MAX('Table'[Month])&&'Table'[IF]=1))
var _day=COUNTX(FILTER(ALL('Table'),'Table'[year]=MAX('Table'[year])&&'Table'[Month]=MAX('Table'[Month])&&'Table'[IF]=1),[date])
return
DIVIDE(_avgamount,_day)
Month forecastB =
var _amount=CALCULATE(SUM('Table'[amount]),FILTER(ALL('Table'),'Table'[year]=MAX('Table'[year])&&'Table'[Month]=MAX('Table'[Month])&&'Table'[IF]=0))
var _day=COUNTX(FILTER(ALL('Table'),'Table'[year]=MAX('Table'[year])&&'Table'[Month]=MAX('Table'[Month])&&'Table'[IF]=0),[date])
return
DIVIDE(_amount * 0.2,_day)
Month forecast =
var _amount=CALCULATE(SUM('Table'[amount]),FILTER(ALL('Table'),'Table'[year]=MAX('Table'[year])&&'Table'[Month]=MAX('Table'[Month])))
return
[Month forecastA]+[Month forecastB] + _amount
Year forecastA =
var _avgamount=CALCULATE(AVERAGE('Table'[amount]),FILTER(ALL('Table'),'Table'[year]=MAX('Table'[year])&&'Table'[IF]=1))
var _day=COUNTX(FILTER(ALL('Table'),'Table'[year]=MAX('Table'[year])&&'Table'[IF]=1),[date])
return
DIVIDE(_avgamount,_day)
Year forecastB =
var _amount=CALCULATE(SUM('Table'[amount]),FILTER(ALL('Table'),'Table'[year]=MAX('Table'[year])&&'Table'[IF]=0))
var _day=COUNTX(FILTER(ALL('Table'),'Table'[year]=MAX('Table'[year])&&'Table'[IF]=0),[date])
return
DIVIDE(_amount * 0.2,_day)
Year forecast =
var _amount=CALCULATE(SUM('Table'[amount]),FILTER(ALL('Table'),'Table'[year]=MAX('Table'[year])))
return
[Year forecastA]+[Year forecastB]+_amount

3. Result:

vyangliumsft_1-1649303541032.png

Please click here for the pbix file

Best Regards,

Liu Yang

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

View solution in original post

3 REPLIES 3
v-yangliu-msft
Community Support
Community Support

Hi  @gauravnarchal ,

Shared link time expired, I created some data:

vyangliumsft_0-1649303541029.png

Here are the steps you can follow:

1. Create calculated column.

year = YEAR('Table'[date])
Month = MONTH('Table'[date])
week = WEEKDAY('Table'[date],2)
IF =
IF(
    'Table'[week]>=1&&'Table'[week]<=5,1,0)

2. Create measure.

Month forecastA =
var _avgamount=CALCULATE(AVERAGE('Table'[amount]),FILTER(ALL('Table'),'Table'[year]=MAX('Table'[year])&&'Table'[Month]=MAX('Table'[Month])&&'Table'[IF]=1))
var _day=COUNTX(FILTER(ALL('Table'),'Table'[year]=MAX('Table'[year])&&'Table'[Month]=MAX('Table'[Month])&&'Table'[IF]=1),[date])
return
DIVIDE(_avgamount,_day)
Month forecastB =
var _amount=CALCULATE(SUM('Table'[amount]),FILTER(ALL('Table'),'Table'[year]=MAX('Table'[year])&&'Table'[Month]=MAX('Table'[Month])&&'Table'[IF]=0))
var _day=COUNTX(FILTER(ALL('Table'),'Table'[year]=MAX('Table'[year])&&'Table'[Month]=MAX('Table'[Month])&&'Table'[IF]=0),[date])
return
DIVIDE(_amount * 0.2,_day)
Month forecast =
var _amount=CALCULATE(SUM('Table'[amount]),FILTER(ALL('Table'),'Table'[year]=MAX('Table'[year])&&'Table'[Month]=MAX('Table'[Month])))
return
[Month forecastA]+[Month forecastB] + _amount
Year forecastA =
var _avgamount=CALCULATE(AVERAGE('Table'[amount]),FILTER(ALL('Table'),'Table'[year]=MAX('Table'[year])&&'Table'[IF]=1))
var _day=COUNTX(FILTER(ALL('Table'),'Table'[year]=MAX('Table'[year])&&'Table'[IF]=1),[date])
return
DIVIDE(_avgamount,_day)
Year forecastB =
var _amount=CALCULATE(SUM('Table'[amount]),FILTER(ALL('Table'),'Table'[year]=MAX('Table'[year])&&'Table'[IF]=0))
var _day=COUNTX(FILTER(ALL('Table'),'Table'[year]=MAX('Table'[year])&&'Table'[IF]=0),[date])
return
DIVIDE(_amount * 0.2,_day)
Year forecast =
var _amount=CALCULATE(SUM('Table'[amount]),FILTER(ALL('Table'),'Table'[year]=MAX('Table'[year])))
return
[Year forecastA]+[Year forecastB]+_amount

3. Result:

vyangliumsft_1-1649303541032.png

Please click here for the pbix file

Best Regards,

Liu Yang

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

parry2k
Super User
Super User

@gauravnarchal what is the logic for the forecast? 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Hi @parry2k  - Here is the logic which I wanted to build

 

Month forecast

A          =          Average total sales of the month on weekdays (Monday to Friday) multiplied by the remaining number of weekdays

B          =          20% of total sales of the month on weekends (Saturday & Sunday) multiplied by the remaining number of weekend days

 

Forecast = Total Sales o fthe month + A + B

 

Yearly forecast

A          =          Average total sales of the year on weekdays (Monday to Friday) multiplied by the remaining number of weekdays

B          =          20% of total sales of the year on weekends (Saturday & Sunday) multiplied by the remaining number of weekend days

 

Forecast = Total Sales of the year + A + B

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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