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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Mharris
Frequent Visitor

Rolling 6 Month Average (new column)

Hello,

I am trying to show the rolling 6 month average in a new column (Column with orange values) shown in the screen shot below.   I need to get the 85% shown which is taking the average from 6/1/2021 - 1/1/2021 (6 months).  

Mharris_0-1650037306070.png

I can't seem to get the DAX logic to work with the new column so I was hoping someone would have some ideas.

 

Thank you!

 

1 ACCEPTED SOLUTION
Whitewater100
Solution Sage
Solution Sage

Hi:

You can do it with easier with the help of a date table. Please see file. I hope you can accept as solution. attached.https://drive.google.com/file/d/1oyxlgh8wvRb2y5eNg8MiTBgkwge5k-zR/view?usp=sharing 

 

Six Month MA =
VAR indexmonth = 'Table'[Month Index]

VAR _measure =
CALCULATE(AVERAGEX( DATESINPERIOD(Dates[Date], LASTDATE(Dates[Date]),-6, MONTH), CALCULATE(SUM('Table'[Percent]))))
RETURN
IF(indexmonth >= 6, _measure, BLANK())
 
Whitewater100_0-1650056097335.png

 

View solution in original post

7 REPLIES 7
Whitewater100
Solution Sage
Solution Sage

Your welcome. Glad it worked for you:-)

Whitewater100
Solution Sage
Solution Sage

Hi:

You can do it with easier with the help of a date table. Please see file. I hope you can accept as solution. attached.https://drive.google.com/file/d/1oyxlgh8wvRb2y5eNg8MiTBgkwge5k-zR/view?usp=sharing 

 

Six Month MA =
VAR indexmonth = 'Table'[Month Index]

VAR _measure =
CALCULATE(AVERAGEX( DATESINPERIOD(Dates[Date], LASTDATE(Dates[Date]),-6, MONTH), CALCULATE(SUM('Table'[Percent]))))
RETURN
IF(indexmonth >= 6, _measure, BLANK())
 
Whitewater100_0-1650056097335.png

 

This was super helpful @Whitewater100 ! Thank you.

Mharris
Frequent Visitor

@tamerj1 so this is a basic excel dumby data screen shot so the date column is just called month and I manually filled out the data shown by month.  I don't have any dax code of the average measue yet, ideally I want to know what that dax code would be to populate a new column where the 85% is showing so I can use that in a more complex setting down the road.

 

@Mharris 

Sorry I meant to ask about the percentage measure no the average. Is it a measure or a column in the raw data? Or this some you need to calculate? The month contains month names or start of month dates? Are looking for a measure or a calculated column?

@tamerj1 No problem at all - the percentage measure in that screen shot is a manual measure inputted.  I created a simpy excel with those % numbers so I could try and get the dax logic that would give me the previous 6 month average which is that 85% column.  The month field is also a manual input and I just did months to make it easier to test the dax logic.  Ideally, I will calculate a new measure field in my real data that will produce a specific % and once I get that % similar to the screen shot %, I will take the average of the previous 6 months of that %.  Let me know if this makes sense.

tamerj1
Super User
Super User

Hi @Mharris 

This is similar to typical moving average. Few  questions. The date column from which table? Is it end of month date or month name? What is the dax code of the average measure?

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.

Top Solution Authors