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
Tvarberg
Helper I
Helper I

Calculate 3 months rolling

 

Looking for advice on how to calculate 3 months rolling average when data are 0 for some months.

I would like to calculate for Full Year but actual data should be used when available.

The first calculation should come in April and use Data for AVERAGE JAN, FEB, MAR

 

 

Data.png

 

 

 

2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

Hi @Tvarberg ,

I have created a simple sample, please refer to my pbix file to see if it helps you.

result =
VAR _1 =
    EDATE ( MAX ( 'Table'[date] ), -3 )
VAR _year =
    YEAR ( _1 )
VAR _month =
    MONTH ( _1 )
VAR _date =
    DATE ( _year, _month, 1 )
VAR _nowdate =
    MAX ( 'Table'[date] )
RETURN
    CALCULATE (
        AVERAGE ( 'Table'[value] ),
        FILTER ( ALL ( 'Table' ), 'Table'[date] >= _date && 'Table'[date] < _nowdate )
    )

vrongtiepmsft_0-1705286529835.png

 

How to Get Your Question Answered Quickly 

 

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

 

Best Regards
Community Support Team _ Rongtie

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

Ashish_Mathur
Super User
Super User

Hi,

Try this approach

  1. Create a Calendar Table with calculated column formulas for Year, Month name and Month number.  Sort the Month name column by the Month number
  2. Create a relationship (Many to One and Single) from the Date column of your Data Table to the Date column of the Calendar Table
  3. To your visual, drag Year and Month name from the Calendar Table
  4. Write these measures

Measure = sum(Data[Revenue])

Rolling average = averagex(SUMMARIZE(calculatetable(Calendar,datesbetween(calendar[date],minx(all(calendar),calendar[date]),max(calendar[date]))),calendar[year],calendar[month name],"ABCD",[Measure]),[ABCD])

Hope this helps.


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

View solution in original post

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

Try this approach

  1. Create a Calendar Table with calculated column formulas for Year, Month name and Month number.  Sort the Month name column by the Month number
  2. Create a relationship (Many to One and Single) from the Date column of your Data Table to the Date column of the Calendar Table
  3. To your visual, drag Year and Month name from the Calendar Table
  4. Write these measures

Measure = sum(Data[Revenue])

Rolling average = averagex(SUMMARIZE(calculatetable(Calendar,datesbetween(calendar[date],minx(all(calendar),calendar[date]),max(calendar[date]))),calendar[year],calendar[month name],"ABCD",[Measure]),[ABCD])

Hope this helps.


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

Hi @Tvarberg ,

I have created a simple sample, please refer to my pbix file to see if it helps you.

result =
VAR _1 =
    EDATE ( MAX ( 'Table'[date] ), -3 )
VAR _year =
    YEAR ( _1 )
VAR _month =
    MONTH ( _1 )
VAR _date =
    DATE ( _year, _month, 1 )
VAR _nowdate =
    MAX ( 'Table'[date] )
RETURN
    CALCULATE (
        AVERAGE ( 'Table'[value] ),
        FILTER ( ALL ( 'Table' ), 'Table'[date] >= _date && 'Table'[date] < _nowdate )
    )

vrongtiepmsft_0-1705286529835.png

 

How to Get Your Question Answered Quickly 

 

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

 

Best Regards
Community Support Team _ Rongtie

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

 

 

 

 

Fowmy
Super User
Super User

@Tvarberg 


Can you share some sample data with the desired output to have a clear understanding of your question?
Mention whether you want a calculated column or measure.
You can either paste your data in the reply box or save it in OneDrive, Google Drive, or any other cloud-sharing platform and share the link here.


 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

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!

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.