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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
gumis_rulez
Helper I
Helper I

Moving average with parameters

Hi,

 

I am trying to calculate moving average which time frame will be affected by choosen month. If I choose May, the Montly Sales Chart is showing data up to May. Would like to achieve also with moving average. Can anybody help me how to make it?

A1.JPG

 

Moving Average Quantity (Months Table) = 
VAR ChoosenMonth = Months[Month Value]
Var ChoosenYear = SELECTEDVALUE('Calendar'[Year_ID])
VAR AverageDay = [Selected Moving Average]

VAR LastTransactionDate = MAX('Calendar'[Transaction_Date])
    
VAR PeriodInVisual = 
FILTER(
    ALL('Calendar'[Transaction_Date]),
    'Calendar'[Transaction_Date] > LastTransactionDate - AverageDay &&
    'Calendar'[Transaction_Date] <= LastTransactionDate
    
)

VAR Result = 
CALCULATE(
    [Average Quantity (Months Table)],
    PeriodInVisual
)
RETURN

Result

 

 

File:

https://drive.google.com/file/d/19l4_3RTl2TfXW8vNQ_Usq45j912IYNua/view?usp=sharing 

 

2 ACCEPTED SOLUTIONS
SachinNandanwar
Super User
Super User

Its due to selection on this slicer 
SachinNandanwar_0-1724193994169.png
So its basically plotting averages X months ahead of a given month

 



Regards,
Sachin
Check out my Blog

View solution in original post

Anonymous
Not applicable

Hi All,
Firstly  SachinNandanwar thank you for your solution!
And @gumis_rulez  to my understanding,you want to align the month in which Moving Average Quantity occurs with the Average Quantity value, your DAX statement is working, the problem is mainly in the field, we can add some filters to our visual object to achieve what you need.

a = IF(
   [Average Quantity (Months Table)]<>BLANK(),
   1,
   0)

vxingshenmsft_1-1724231630683.png

 

vxingshenmsft_0-1724231605207.png

 

Hope it helps!

 

Best regards,
Community Support Team_ Tom Shen

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

2 REPLIES 2
Anonymous
Not applicable

Hi All,
Firstly  SachinNandanwar thank you for your solution!
And @gumis_rulez  to my understanding,you want to align the month in which Moving Average Quantity occurs with the Average Quantity value, your DAX statement is working, the problem is mainly in the field, we can add some filters to our visual object to achieve what you need.

a = IF(
   [Average Quantity (Months Table)]<>BLANK(),
   1,
   0)

vxingshenmsft_1-1724231630683.png

 

vxingshenmsft_0-1724231605207.png

 

Hope it helps!

 

Best regards,
Community Support Team_ Tom Shen

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

 

SachinNandanwar
Super User
Super User

Its due to selection on this slicer 
SachinNandanwar_0-1724193994169.png
So its basically plotting averages X months ahead of a given month

 



Regards,
Sachin
Check out my Blog

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.