Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Ibrahim_shaik
Helper V
Helper V

Dynamic Average per month Calculation

Hi Power Bi Community,

 

I have a Power Usage column(hourly data), date table from last Year till today and I want to calculate the daily average power for a month and every month will have a different average and when i select any day or multiple days from the current month or previous month from the date slicer it should return that particular month last year daily average value. User can select 1 day or 2 day or week, month, Year depending on the selection it should return the average for that period and if the user selects one day then also it should return same month last year daily average.

 

For Instance if i select 5th Aug 25 then it should return same month last year daily average.

 

Daily Average Calculation = SUM(Individual days Power)/Total no.of days.

 

Please let me know how i can achieve this.

 

Thanks & Regards,

Ibrahim.   

5 REPLIES 5
v-sdhruv
Community Support
Community Support

Hi @Ibrahim_shaik ,

Just wanted to check if you got a chance to review the suggestions provided and whether that helped you resolve your query?

Thank You

sreejad
Frequent Visitor

Hi @Ibrahim_shaik 

Assuming you have a claendar table and relationship with corresponding fact table. 

Previous Year Average =
var selecteddates=values('Calendar'[Date])
var preYeardates=SELECTCOLUMNS(ADDCOLUMNS('Calendar',"prevyerdate",DATE(year('Calendar'[Date])-1,MONTH('Calendar'[Date]),DAY('Calendar'[Date]))),"Date",[prevyerdate])
return
CALCULATE(DailyAverage,TREATAS(preYeardates,'Calendar'[Date]))

DailyAverage is nothing but the formula you already mentioned. 

Daily Average Calculation = SUM(Individual days Power)/Total no.of days.

Hope this works.

 

Thanks.

Hi @sreejad ,

 

Thank you for the solution.

bhanu_gautam
Super User
Super User

@Ibrahim_shaik 

Ensure you have a separate date table in your model. T

 Make sure your date table is related to your power usage data table through the date column.

You can create a measure to calculate the daily average power usage for the selected period.

DAX
DailyAveragePower =
VAR SelectedDays = COUNTROWS(VALUES('DateTable'[Date]))
RETURN
IF(
SelectedDays > 0,
DIVIDE(SUM('PowerUsageTable'[PowerUsage]), SelectedDays),
BLANK()
)

 

Create a Measure for Last Year's Daily Average: This measure will calculate the daily average for the same month in the previous year.

LastYearDailyAveragePower =
VAR CurrentMonth = MONTH(SELECTEDVALUE('DateTable'[Date]))
VAR CurrentYear = YEAR(SELECTEDVALUE('DateTable'[Date]))
VAR LastYear = CurrentYear - 1
RETURN
CALCULATE(
[DailyAveragePower],
FILTER(
ALL('DateTable'),
MONTH('DateTable'[Date]) = CurrentMonth &&
YEAR('DateTable'[Date]) = LastYear
)
)

 




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Hi @bhanu_gautam , @v-sdhruv 

 

Sorry for the late response.

 

Thank you so much for providing the solution. I will try this measure and will let you know.

 

Thank you once again.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.