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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
yaya1974
Helper III
Helper III

8 month average new column

Hello,  I am trying to calculate my 8 month average (Jan-Aug) to populate for remainder of year (Sep-Dec)

Can anyone help?

MonthActualsAverageTotal
Jan148 1440
Feb222 1440
Mar120 1440
Apr39 1440
May94 1440
Jun73 1440
Jul85 1440
Aug179 1440
Sep 1201440
Oct 1201440
Nov 1201440
Dec 1201440

 

 

Thanks for the help!!!

Lori

1 ACCEPTED SOLUTION

hello @yaya1974 

 

i dont know how your year value in your data, but you can simply add year value as filter.

Average =
var _Num = MONTH(CONVERT("2024-"&'Table'[Month]&"-1",DATETIME))
Return
IF(
    _Num>8&&VALUE('Table'[Column1])=YEAR(TODAY()),
    AVERAGEX(FILTER(ALL('Table'),VALUE('Table'[Column1])=YEAR(TODAY())),'Table'[Actuals]),
    BLANK()
)

Irwan_2-1726012856774.png

as you can see, add in if statement and you can do average on all data before September in on-going year.

 

But if you want to calculate each year, you can add filter in AVERAGEX

Average = 
var _Num = MONTH(CONVERT("2024-"&'Table'[Month]&"-1",DATETIME))
Return
IF(
    _Num>8,
    AVERAGEX(FILTER(ALL('Table'),VALUE('Table'[Column1])=YEAR(TODAY())),'Table'[Actuals]),
    BLANK()
)

Irwan_1-1726012802691.png

 

Hope this will help.

Thank you.

View solution in original post

10 REPLIES 10
muhammad_786_1
Super User
Super User

You can handle the missing data for the remainder of the year (Sep-Dec) by using this M code:

 

Result.PNG

JanToAug = Table.SelectRows(#"Changed Type", each [MonthNo] >= 1 and [MonthNo] <= 8),
AvgActuals = List.Average(List.RemoveNulls(JanToAug[Actuals])),
AddNewCol = Table.AddColumn(#"Changed Type", "NewCol", each if [Actuals] = null then AvgActuals else [Actuals], Int64.Type)

 

I've also attached a link to a reference file that you can check for more details

 

File

 

Best Regards,
Muhammad Yousaf

 

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

 

LinkedIn

Hello.  Thank you for the help.  I cannot access your file, my company blocked it.  Can you send pbix file?

 

 

Irwan
Super User
Super User

hello @yaya1974 

 

is this what you are looking for?

Irwan_0-1725926808969.png

 

create a calculated column with following DAX.

Average =
var _Num = MONTH(CONVERT("2024-"&'Table'[Month]&"-1",DATETIME))
Return
IF(
    _Num>8,
    AVERAGEX(ALL('Table'),'Table'[Actuals]),
    BLANK()
)
 
Hope this will help.
Thank you.

Hi.  Thank you.   That works, however, I have multiple years, so having a formula looking at just a specific year does not work.  I need a formula  that will filter on the year and the customer and the model.

Appreciate your help!

Hi,

Share data for multiple years and show the expected result.  Share data in a format that can be pasted in an MS Excel file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

hello @yaya1974 

 

i dont know how your year value in your data, but you can simply add year value as filter.

Average =
var _Num = MONTH(CONVERT("2024-"&'Table'[Month]&"-1",DATETIME))
Return
IF(
    _Num>8&&VALUE('Table'[Column1])=YEAR(TODAY()),
    AVERAGEX(FILTER(ALL('Table'),VALUE('Table'[Column1])=YEAR(TODAY())),'Table'[Actuals]),
    BLANK()
)

Irwan_2-1726012856774.png

as you can see, add in if statement and you can do average on all data before September in on-going year.

 

But if you want to calculate each year, you can add filter in AVERAGEX

Average = 
var _Num = MONTH(CONVERT("2024-"&'Table'[Month]&"-1",DATETIME))
Return
IF(
    _Num>8,
    AVERAGEX(FILTER(ALL('Table'),VALUE('Table'[Column1])=YEAR(TODAY())),'Table'[Actuals]),
    BLANK()
)

Irwan_1-1726012802691.png

 

Hope this will help.

Thank you.

I got it!!! YAYYYYY   finally 🙂   Thank you 😀

Here is excel example simplified:

MonthYearCustomerModelFinishActuals (Jan-Aug)Average (Sep-Dec)
Jan2023ATS148 
Feb2023BTAC222 
Mar2023ATAC120 
Apr2023ATAC39 
May2023BUS94 
Jun2023BUS73 
Jul2023AUS85 
Aug2023BUAC17 
Sep2023ATAC 127
Oct2023ATAC 127
Nov2023ATAC 127
Dec2023ATAC 127
Jan2024AUS153 
Feb2024BUS227 
Mar2024AUS125 
Apr2024AUAC44 
May2024BTS99 
Jun2024BTS78 
Jul2024ATS90 
Aug2024BTAC22 
Sep2024BUS 168
Oct2024BUS 168
Nov2024BUS 168
Dec2024BUS 168

ok but I need it filtered even farther down.  Not sure by year, but by customer and model and finish.  averagex only allows one filter.   the actuals are different for different years, but your formula above is only giving me the same answer for all the years.   I will put in excel data I am looking for and hopefully you can help me?!!   Thank you!

yaya1974
Helper III
Helper III

Oh wait,  plus filter on customer, year, model, finish

Thank you!

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! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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