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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
Anonymous
Not applicable

Calculating Average

I need to represent the average per year from the following. The values in the matrix are the Count of Distinct (Name). The dates are (Created Date). It's okay if it requires a separate table visual. 

 

The goal is 2017 to calculate as 185 (sum of distinct names in 2017) divided by 12 (number of months), for example.

 

Even better would be if 2023 can limit to only through the previous month. For example, it is July today. I'd want the sum of distinct names through January 2023-June 2023 divided by 6 (months)

 

 

kault_0-1690034241241.png

2 REPLIES 2
foodd
Super User
Super User

Please provide your work-in-progress Power BI Desktop file (with sensitive information removed) that covers your issue or question completely in a usable format (not as a screenshot).


https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...


Please show the expected outcome based on the sample data you provided.

https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

 

This allows members of the Forum to assess the state of the model, report layer, relationships, and any DAX applied.

connect
Resolver I
Resolver I

Hi, 
Try the following DAX Code: 

AveragePerYear =
VAR CurrentYear = YEAR(MAX('YourTable'[Month]))
VAR PreviousMonth = IF(MONTH(TODAY()) > 1, MONTH(TODAY()) - 1, 1)
VAR StartYear = IF(CurrentYear = 2023, 2017, 0)
VAR EndYear = IF(CurrentYear = 2023, 2022, CurrentYear)
VAR TotalMonths = IF(CurrentYear = 2023, PreviousMonth, 12)

RETURN
DIVIDE(
CALCULATE(DISTINCTCOUNT('YourTable'[Name]),
'YourTable'[Month] >= DATE(StartYear, 1, 1),
'YourTable'[Month] <= DATE(EndYear, TotalMonths, 1)
),
IF(CurrentYear = 2023, TotalMonths, 12)
)

Give it a Thumbs up if this solves your challenge. 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

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.