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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

How to calculate average based on month selected from different Years

I have 2 table dates and Transactions

date table has data (all days and months)

YearMOnthdateReportYear
2018jan01/01/2018Previous year
2018jan02/01/2018Previous year
2018feb Previous Year
2019Jan Current Year
2019feb Current Year

Now I have transaction Table

YearStreamHour
2018a10
2018a20
2019a30
2019a40

Both the table are joined on Year column

Now i have 2 slicer 

  • Month
  • Report Year

and a table which shows

Streamtotal Hours
  •  Previous year hours = 30. 
  • Selected months = Jan
  • total hour= Monthly average  = 30/12 x 1
When multiple FYs is selected:
  •  current Year hour= 30 
  • Previous year = 70
  • Selected months = Jan 2018+Jan 2019+Feb 2019 = 3 months
  • Total hours = (30/12) x 1 + (70/12) x 2
1 REPLY 1
rajendraongole1
Super User
Super User

Hi @Anonymous - Please try to create the below measures: if the issue is not closed.

 

reference link:

Solved: calculate average based on academic year - Microsoft Fabric Community

 

Try below measures:

 

// Measure for Total Hours in the Current Year
TotalHoursCurrentYear =
CALCULATE(
SUM(Transactions[Hour]),
FILTER('Date', 'Date'[ReportYear] = "Current Year")
)

// Measure for Total Hours in the Previous Year
TotalHoursPreviousYear =
CALCULATE(
SUM(Transactions[Hour]),
FILTER('Date', 'Date'[ReportYear] = "Previous Year")
)

// Measure for Monthly Average Hours in the Current Year
MonthlyAverageHoursCurrentYear =
DIVIDE([TotalHoursCurrentYear], 12)

// Measure for Monthly Average Hours in the Previous Year
MonthlyAverageHoursPreviousYear =
DIVIDE([TotalHoursPreviousYear], 12)

// Measure for Selected Months
SelectedMonths =
COUNTROWS(
VALUES('Date'[Month])
)

// Measure for Total Selected Hours
TotalSelectedHours =
DIVIDE([TotalHoursPreviousYear], 12) * [SelectedMonths] +
DIVIDE([TotalHoursCurrentYear], 12) * [SelectedMonths]

// Measure for Display in the Table
DisplayTotalHours =
SUMX(
VALUES(Transactions[Stream]),
[TotalSelectedHours]
)

 

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors