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

Moving average of a measure

Hi,

 

Apologies for raising an issue that's been raised many times before, but I've tried the solutions and they haven't worked for me.

 

I have a query with a big list of application numbers, their date, and the number of working days it took to process them. I have created a measure called "Percentage Ten Working Days or Under" that calculates the percentage of these apps processed in ten working days or under.

 

Percentage Ten Working Days or Under = CALCULATE(COUNTROWS('FACT-Applications'),'FACT-Applications'[WorkDays]<=10)/COUNTROWS('FACT-Applications')

 

I have also made a graph displaying this measure over time, by month based on my Date Table:

 

Capture.PNG

 

Now, I'd really like to run a six-month rolling average of this measure on this graph as well. I put in this DAX code based on another forum post:

 

Rolling Average of Percentage Ten Working Days or Under =
CALCULATE (
    AVERAGEX ('FACT-Applications', [Percentage Ten Working Days or Under]),
    DATESINPERIOD (
        'Calendar'[Date],
        LASTDATE ( 'Calendar'[Date]),
        -6,
        MONTH
 )
)

 

But it produced:

 

sdfsd.PNG

Which is clearly not right. What am I doing wrong? Sorry in advance but I won't be able to share the pbix because it has sensitive personal information in it.

1 ACCEPTED SOLUTION
adambhappy
Resolver II
Resolver II

The AVERAGEX does a context transition to row level, i.e. for each single row in the fact table you are trying to average the result of the percentage measure which doesn't make much sense. Change the first parameter in the AVERAGEX() to your datetable and it should be fine.

Rolling Average of Percentage Ten Working Days or Under =
CALCULATE (
    AVERAGEX ('Calendar'[Date]', [Percentage Ten Working Days or Under]),
    DATESINPERIOD (
        'Calendar'[Date],
        LASTDATE ( 'Calendar'[Date]),
        -6,
        MONTH
 )
)

View solution in original post

2 REPLIES 2
adambhappy
Resolver II
Resolver II

The AVERAGEX does a context transition to row level, i.e. for each single row in the fact table you are trying to average the result of the percentage measure which doesn't make much sense. Change the first parameter in the AVERAGEX() to your datetable and it should be fine.

Rolling Average of Percentage Ten Working Days or Under =
CALCULATE (
    AVERAGEX ('Calendar'[Date]', [Percentage Ten Working Days or Under]),
    DATESINPERIOD (
        'Calendar'[Date],
        LASTDATE ( 'Calendar'[Date]),
        -6,
        MONTH
 )
)
Anonymous
Not applicable

Cheers, adambhappy! I now understand the AVERAGEX function.

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.