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 Average of past 1 year not working when I put "MMM YYYY" field

I have created a measure for a rolling average of SumofSales(Measure) for past 1 year. the below code is working great as long as I keep the 'Sales_Data[EndofMonthDate]' field in the table visualisation. Because I want to visualize the data by Month and Year and If I want to see it by 'Sales_Data[MonthYear]'(which is MMM YYYY Format) it is not working.  I tried so much and could not complete it. Can anyone please help?

 

MovingAverageofTotalSales =
AVERAGEX (
    DATESINPERIOD (
        Sales_Data[EndofMonthDate],
        MAX ( Sales_Data[EndofMonthDate] ),
        -1,
        YEAR
    ),
    [SumofSales]
)
1 ACCEPTED SOLUTION
v-lionel-msft
Community Support
Community Support

Hi @Anonymous ,

 

Even if I changed the format of the date column, it will not affect the result of the measure. Dates in different formats are just different in visual effect.

p1.PNGp2.PNG

 

Could you share a sample data and the formula of [SumofSales]?

 

Best regards,
Lionel Chen

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
v-lionel-msft
Community Support
Community Support

Hi @Anonymous ,

 

Even if I changed the format of the date column, it will not affect the result of the measure. Dates in different formats are just different in visual effect.

p1.PNGp2.PNG

 

Could you share a sample data and the formula of [SumofSales]?

 

Best regards,
Lionel Chen

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

 

Anonymous
Not applicable

Wow! I tried the format the date field as MMM YYYY and then it worked for me! Thankssomuch!! @v-lionel-msft 

 

Previously I have changed the Sales_Data[EndofMonthDate] as categorical in x-axis and removed hierarchy then it showed the month end dates in the x-axis. But what I wanted was to see Month and Year just in MMM YYYY format. For this I created a separate calculated column on date as below:

MonthYear = FORMAT((Sales_Data[EndofMonthDate]),"MMM") & " " & YEAR(Sales_Data[EndofMonthDate])

 

but now I changed the format of the field Sales_Data[EndofMonthDate] into MMM YYYY as you have shown below and also put categorical in x-axis . It worked now.

 

and below is the sum of sales that I am doing and I hope this is correct. let me know.

SumofSales = CALCULATE(SUM(Sales_Data[Total Sales]))
 
Thank you so much again @v-lionel-msft 
 
Regards,
gcp

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.