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
Anonymous
Not applicable

Rolling 3 month average by person?

I have data that consists of persons name[Co-ordinator], month (dd/mm/yyyy format) [Month Completed] and the total completed tasks for that month [Count]. I have been asked to show the last 3 months average for each person. Can anyone please help with this as would be helpful to create other reports but for now I just need a bit of help achieving this. Thanks in advance.

1 ACCEPTED SOLUTION

Hi @Anonymous ,

 

Dax functions like DATESINPERIOD are time intelligence functions. There should be a related DimDate table with continuous dates when you use these functions.

I think you can try my code to create a measure without adding an related DimDate table.

My Sample:

RicoZhou_0-1650854345692.png

Measure:

Rolling 3 month average by person = 
VAR _LASTMONTH =
    MAX ( 'Table'[Month] )
VAR _STARTMONTH =
    EOMONTH ( _LASTMONTH, -3 ) + 1
RETURN
    CALCULATE (
        AVERAGE ( 'Table'[Count] ),
        FILTER (
            ALLEXCEPT ( 'Table', 'Table'[Co-ordinator] ),
            'Table'[Month] >= _STARTMONTH
        )
    )

Result is as below.

RicoZhou_1-1650854371907.png

 

Best Regards,
Rico Zhou

 

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

4 REPLIES 4
Ashish_Mathur
Super User
Super User

Hi,

Share some data and show the expected result.


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

@Anonymous , with help from a date table, view data by person

 

Rolling 3 = calculate(AverageX(Values('Date'[MONTH Year]),CALCULATE(sum(Sales[Sales Amount]))),DATESINPERIOD('Date'[Date ],MAX('Date'[Date ]),-3,MONTH))

Anonymous
Not applicable

Hi and thanks for the reply. Can you explain what you mean please 'with help from a date table' ?

Also not quite sure how it determines when the data changes from one person to another?

Hi @Anonymous ,

 

Dax functions like DATESINPERIOD are time intelligence functions. There should be a related DimDate table with continuous dates when you use these functions.

I think you can try my code to create a measure without adding an related DimDate table.

My Sample:

RicoZhou_0-1650854345692.png

Measure:

Rolling 3 month average by person = 
VAR _LASTMONTH =
    MAX ( 'Table'[Month] )
VAR _STARTMONTH =
    EOMONTH ( _LASTMONTH, -3 ) + 1
RETURN
    CALCULATE (
        AVERAGE ( 'Table'[Count] ),
        FILTER (
            ALLEXCEPT ( 'Table', 'Table'[Co-ordinator] ),
            'Table'[Month] >= _STARTMONTH
        )
    )

Result is as below.

RicoZhou_1-1650854371907.png

 

Best Regards,
Rico Zhou

 

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

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.