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
Ben-Jy
Frequent Visitor

Average of amount of two dates per months

Hello,

 

I have this table : 

 

Ben-Jy_0-1598262238794.png

 

It represents the stock of a company at the end of the month. I have to calculate the average of the stock per month, during the 12 last months. I used a formula for rolling average but the results were not those expected.

Instead, I would like to calculate the average amount for the current month and the month a year ago. So I would only make an average of two dates.

For example, if we want to calculate this average for the month of July 2020, the results would be the average of the amount of the stock for the month of July and the amount of the stock for the month of August 2019. 

So the numerical result in my example would be : (188669 + 216749)/2 = 202709

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Ben-Jy ,

Rolling 12 á CALCULATE(CLOSINGBALANCEMONTH(sum(Sales[Sales Amount]),'Date'[Date] ),DATESINPERIOD('Date'[Date],ENDOFMONTH(Sales[Sales Date]),-12,MONTH))
Rolling 12 á CALCULATE(CLOSINGBALANCEMONTH(sum(Sales[Sales Amount]),'Date'[Date]),DATESINPERIOD('Date'[Date ],MAX(Sales[Sales Date]),-12,MONTH))

los dos últimos meses CLOSINGBALANCEMONTH(sum(Sales[Sales Amount]),dateadd('Date'[Date],-1,month) + CLOSINGBALANCEMONTH(sum(Sales[Sales Amount])

Power BI — MTD
https://medium.com/@amitchandak.1978/power-bi-mtd-questions-time-intelligence-3-5-64b0b4a4090e

To get the best out of the weather intelligence feature. Make sure that you have a date calendar and that it has been marked as the date in the model view. Also, join it with the date column of your made/s. See:
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

See if my Time Intelligence webinar can help: https://community.powerbi.com/t5/Webinars-and-Video-Gallery/PowerBI-Time-Intelligence-Calendar-WTD-Y...


We appreciate your congratulations.

View solution in original post

1 REPLY 1
amitchandak
Super User
Super User

@Ben-Jy ,

Rolling 12 á CALCULATE(CLOSINGBALANCEMONTH(sum(Sales[Sales Amount]),'Date'[Date] ),DATESINPERIOD('Date'[Date],ENDOFMONTH(Sales[Sales Date]),-12,MONTH))
Rolling 12 á CALCULATE(CLOSINGBALANCEMONTH(sum(Sales[Sales Amount]),'Date'[Date]),DATESINPERIOD('Date'[Date ],MAX(Sales[Sales Date]),-12,MONTH))

los dos últimos meses CLOSINGBALANCEMONTH(sum(Sales[Sales Amount]),dateadd('Date'[Date],-1,month) + CLOSINGBALANCEMONTH(sum(Sales[Sales Amount])

Power BI — MTD
https://medium.com/@amitchandak.1978/power-bi-mtd-questions-time-intelligence-3-5-64b0b4a4090e

To get the best out of the weather intelligence feature. Make sure that you have a date calendar and that it has been marked as the date in the model view. Also, join it with the date column of your made/s. See:
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

See if my Time Intelligence webinar can help: https://community.powerbi.com/t5/Webinars-and-Video-Gallery/PowerBI-Time-Intelligence-Calendar-WTD-Y...


We appreciate your congratulations.

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.