Forum Discussion
Dynamic Average per month Calculation
- 1 year ago
To calculate daily average power usage for the same month last year based on any date selection:
Detect the selected date(s).
Shift to the same month in the previous year.
Sum power usage for that month.
Divide by number of days in that month.DailyAvgPower_LastYearMonth =
VAR SelectedMonth = MONTH(MIN('DateTable'[Date]))
VAR SelectedYear = YEAR(MIN('DateTable'[Date])) - 1
VAR DatesLastYear = FILTER(
ALL('DateTable'),
MONTH('DateTable'[Date]) = SelectedMonth &&
YEAR('DateTable'[Date]) = SelectedYear
)
RETURN
DIVIDE(
CALCULATE(SUM(PowerUsage[Usage]), DatesLastYear),
CALCULATE(DISTINCTCOUNT('DateTable'[Date]), DatesLastYear)
)
Hi Ibrahim_shaik ,
I hope your query got resolved. Thank you Shahid12523 for sharing your input.
We would be closing this thread, if you still need any assistance, feel free to reach out by creating a new post.
Thank you for using Microsoft Community Forum
Hi v-sdhruv Shahid12523 ,
Apologies for late response.
Thank you for providing the solution Shahid12523
My query is resolved.